Pie Label Format

The above example shows you how to create PieChart using D3 package. In this example, for purpose of chart demonstration only, we do use mock-up data from array. As you can see, the KoolReport's widget in general support dataSource could be DataStore, Process, DataSource or even simple array.

The example show how to create pie chart with label format.

Set formatter for the label on each pie piece.

Default: undefined

For example:

...
"options" => array(
        "pie" => array(
            "label" => array(
                "format" => "function(value, ratio, id){
                    return '$' + value;
                }"
            )
        )
    )
<?php
require_once "../../../../load.koolreport.php";
require_once "MyReport.php";
$report = new MyReport;
$report->run();
$report->render();
<?php

class MyReport extends \koolreport\KoolReport
{

}
<h1 class='title'>Pie Label Format </h1>
<div style="display: flex;justify-content: center;">
    <?php
    $data = [
        ['label' =>  'data1', 'data' => 30],
        ['label' => 'data2', 'data' => 50],
    ];

    \koolreport\d3\PieChart::create(array(
        "dataSource" => $data,
        "columns" => array(
            'label',
            'data'
        ),
        "options" => array(
            "pie" => array(
                "label" => array(
                    "format" => "function(value, ratio, id){
                        return '$' + value;
                    }"
                )
            )
        )
    ));
    ?>
</div>

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro