Line Chart

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

This example shows how to build line charts with different point styles using the pointStyle property.

When a string is provided, the following values are supported:

'circle'
'cross'
'crossRot'
'dash'
'line'
'rect'
'rectRounded'
'rectRot'
'star'
'triangle'
false

If the value is an image or a canvas element, that image or canvas element is drawn on the canvas using drawImage .

For example:

...
"options" => array(
    ...
    "elements" => array(
        "point" => array(
            "pointStyle" => 'circle'
        )
    )
)
...
<?php
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
require_once "../../../load.koolreport.php";
require_once "MyReport.php";
$report = new MyReport;
$report->run();
$report->render();
?>

<html>

<head>
    <title>
        Line Chart 
    </title>
</head>

<body>
</body>

</html>
<?php
class MyReport extends \koolreport\KoolReport
{
    
}
<div id="report_render" style="display: flex;flex-direction: row;flex-wrap: wrap;justify-content: center;">
    <?php
    function randomScalingFactor()
    {
        return mt_rand(-100, 100);
    }

    $shape = ['circle', 'triangle', 'rect', 'rectRounded', 'rectRot', 'cross', 'crossRot', 'star', 'line', 'dash'];

    $data = [
        ['month' => 'January',   'value' => 10],
        ['month' => 'February',  'value' => 23],
        ['month' => 'March',     'value' => 5],
        ['month' => 'April',     'value' => 99],
        ['month' => 'May',       'value' => 67],
        ['month' => 'June',      'value' => 43],
        ['month' => 'July',      'value' => 0],
    ];

    for ($i = 0; $i < count($shape); $i++) {
    ?>
        <div style="width: 500px;margin-left: 40px;margin-right: 40px;margin-bottom: 40px;">
            <?php
            \koolreport\chartjs\LineChart::create(
                array(
                    'dataSource' => $data,
                    'columns' => array(
                        'month',
                        'value' => array(
                            "showLine" => false,
                            "pointRadius" => 10,
                            "pointHoverRadius" => 15,
                            "backgroundColor" => 'rgb(255, 99, 132)',
                            "borderColor" => 'rgb(255, 99, 132)',
                            "fill" => false,
                            "label" => "My First dataset"
                        )
                    ),
                    "options" => array(
                        "responsive" => true,
                        "title" => array(
                            "display" => true,
                            "text" => "Point Style: " . $shape[$i]
                        ),
                        "legend" => array(
                            "display" => false,
                        ),
                        "elements" => array(
                            "point" => array(
                                "pointStyle" => $shape[$i]
                            )
                        )
                    )
                )
            );
            ?>
        </div>
    <?php
    }
    ?>
</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