Region

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.

The example show how to create line chart with region.

Show rectangles inside the chart.

This option accepts array including object that has axis, start, end and class. The keys start, end and class are optional.

axis must be x, y or y2. start and end should be the value where regions start and end. If not specified, the edge values will be used. If timeseries x axis, date string, Date object and unixtime integer can be used. If class is set, the region element will have it as class.

Default: []

For example:

...
"options" => array(
    ...
    "regions" => array(
        array(
            "axis" => 'x',
            "end" => 1,
            "class" => 'regionX'
        ),
        array(
            "axis" => 'x',
            "start" => 2,
            "end" => 4,
            "class" => 'regionX'
        ),
        array(
            "axis" => 'x',
            "start" => 5,
            "class" => 'regionX'
        ),
        ...
    )
)
<?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'>Region</h1>
<style>
    .c3-region.regionY {
        fill: red;
    }

    .c3-region.regionY2 {
        fill: green;
    }
</style>
<?php
$data = [
    ['data1' =>  30, 'data2' =>  830],
    ['data1' => 200, 'data2' => 1200],
    ['data1' => 100, 'data2' => 1100],
    ['data1' => 400, 'data2' => 1400],
    ['data1' => 150, 'data2' => 1150],
    ['data1' => 250, 'data2' => 1250],
    ['data1' => 400, 'data2' => 1500]
];

\koolreport\d3\LineChart::create(array(
    "dataSource" => $data,
    "columns" => array(
        'data1',
        'data2'
    ),
    "options" => array(
        "data" => array(
            "axes" => array(
                "data2" => 'y2'
            )
        ),
        "axis" => array(
            "y2" => array(
                "show" => true
            )
        ),
        "regions" => array(
            array(
                "axis" => 'x',
                "end" => 1,
                "class" => 'regionX'
            ),
            array(
                "axis" => 'x',
                "start" => 2,
                "end" => 4,
                "class" => 'regionX'
            ),
            array(
                "axis" => 'x',
                "start" => 5,
                "class" => 'regionX'
            ),
            array(
                "axis" => 'y',
                "end" => 50,
                "class" => 'regionY'
            ),
            array(
                "axis" => 'y',
                "start" => 80,
                "end" => 140,
                "class" => 'regionY'
            ),
            array(
                "axis" => 'y',
                "start" => 400,
                "class" => 'regionY'
            ),
            array(
                "axis" => 'y2',
                "end" => 900,
                "class" => 'regionY2'
            ),
            array(
                "axis" => 'y2',
                "start" => 1150,
                "end" => 1250,
                "class" => 'regionY2'
            ),
            array(
                "axis" => 'y2',
                "start" => 1300,
                "class" => 'regionY2'
            )
        )
    )
));

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