LineChart

This example shows how to use D3's LineChart

Basic chart
BooksAccessoriesPhonesMoviesOthers500010000150002000025000300003500040000450005000055000BooksAccessoriesPhonesMoviesOthersSaleCostProfit
Dual Axis - Sale and Sale Number
BooksAccessoriesPhonesMoviesOthers$10,000$15,000$20,000$25,000$30,000$35,000$40,000$45,000$50,000$55,000100020003000400050006000700080009000BooksAccessoriesPhonesMoviesOthersSaleCost
Time series
Sep 01, 2018Sep 02, 2018Sep 04, 2018Sep 05, 2018Sep 09, 20183200034000360003800040000420004400046000Sep 01, 2018Sep 02, 2018Sep 04, 2018Sep 05, 2018Sep 09, 2018Sale Amount

The above example shows you how to create LineChart 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.

<?php

require_once "../../../load.koolreport.php";
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php

class MyReport extends \koolreport\KoolReport
{

}
<?php
    use \koolreport\d3\LineChart;

    $category_amount = array(
        array("category"=>"Books","sale"=>32000,"cost"=>20000,"profit"=>12000),
        array("category"=>"Accessories","sale"=>43000,"cost"=>36000,"profit"=>7000),
        array("category"=>"Phones","sale"=>54000,"cost"=>39000,"profit"=>15000),
        array("category"=>"Movies","sale"=>23000,"cost"=>18000,"profit"=>5000),
        array("category"=>"Others","sale"=>12000,"cost"=>6000,"profit"=>6000),
    );

    $category_sale_month = array(
        array("category"=>"Books","January"=>32000,"February"=>20000,"March"=>12000),
        array("category"=>"Accessories","January"=>43000,"February"=>36000,"March"=>7000),
        array("category"=>"Phones","January"=>54000,"February"=>39000,"March"=>15000),
        array("category"=>"Others","January"=>12000,"February"=>6000,"March"=>6000),
    );
?>
<div class="report-content">
    <div class="text-center">
        <h1>LineChart</h1>
        <p class="lead">
            This example shows how to use D3's LineChart
        </p>
    </div>
    <div style="margin-bottom:50px;">
    <div class="text-center"><strong>Basic chart</strong></div>
    <?php
    LineChart::create(array(
        "dataSource"=>$category_amount,
        "columns"=>array(
            "category",
            "sale"=>array("label"=>"Sale","type"=>"number","prefix"=>"$"),
            "cost"=>array("label"=>"Cost","type"=>"number","prefix"=>"$"),
            "profit"=>array("label"=>"Profit","type"=>"number","prefix"=>"$"),
        )
    ));
    ?>
    </div>
    
    <div style="margin-bottom:50px;">
    <div class="text-center"><strong>Dual Axis - Sale and Sale Number</strong></div>
    <?php
    LineChart::create(array(
        "dataSource"=>array(
            array("category"=>"Books","sale"=>32000,"number"=>1700,),
            array("category"=>"Accessories","sale"=>43000,"number"=>2100),
            array("category"=>"Phones","sale"=>54000,"number"=>3200),
            array("category"=>"Movies","sale"=>23000,"number"=>9000),
            array("category"=>"Others","sale"=>12000,"number"=>5300),
        ),
        "columns"=>array(
            "category",
            "sale"=>array(
                "label"=>"Sale",
                "type"=>"number",
                "prefix"=>"$"
            ),
            "number"=>array(
                "label"=>"Cost",
                "type"=>"number",
                "prefix"=>"$",
                "axis"=>"y2"
            ),
        ),
        "yAxis"=>array(
            "prefix"=>"$"
        ),
        "dualAxis"=>true
    ));
    ?>
    </div>

    <div style="margin-bottom:50px;">
    <div class="text-center"><strong>Time series</strong></div>
    <?php
    LineChart::create(array(
        "dataSource"=>array(
            array("date"=>"2018-09-01","sale"=>32000),
            array("date"=>"2018-09-02","sale"=>43000),
            array("date"=>"2018-09-04","sale"=>33000),
            array("date"=>"2018-09-05","sale"=>40000),
            array("date"=>"2018-09-09","sale"=>45000),
        ),
        "columns"=>array(
            "date"=>array(
                "type"=>"date",
                "xFormat"=>"%Y-%m-%d",
                "xDisplayFormat"=>"%b %d, %Y"
            ),
            "sale"=>array(
                "label"=>"Sale Amount",
                "type"=>"number",
                "prefix"=>"$"
            ),
        )
    ));
    ?>
    </div>


</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