Line Styles

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 line styles using the borderDash and fill properties.

For example:

...
'columns' => array(
    'month',
    'Unfilled' => array(
        ...
    ),
    'Dashed' => array(
        "borderDash" => [5, 5],
        ...
    ),
    'Filled' => array(
        "fill" => true,
        ...
    )
)
...
<?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 Styles 
    </title>
</head>

<body>
</body>

</html>
<?php
class MyReport extends \koolreport\KoolReport
{
    
}
<div id="report_render">
    <?php
    function randomScalingFactor()
    {
        return mt_rand(-100, 100);
    }

    $data = [
        ['month' => 'February',  'Unfilled' => randomScalingFactor(), 'Dashed' => randomScalingFactor(), 'Filled' => randomScalingFactor()],
        ['month' => 'January',   'Unfilled' => randomScalingFactor(), 'Dashed' => randomScalingFactor(), 'Filled' => randomScalingFactor()],
        ['month' => 'March',     'Unfilled' => randomScalingFactor(), 'Dashed' => randomScalingFactor(), 'Filled' => randomScalingFactor()],
        ['month' => 'April',     'Unfilled' => randomScalingFactor(), 'Dashed' => randomScalingFactor(), 'Filled' => randomScalingFactor()],
        ['month' => 'May',       'Unfilled' => randomScalingFactor(), 'Dashed' => randomScalingFactor(), 'Filled' => randomScalingFactor()],
        ['month' => 'June',      'Unfilled' => randomScalingFactor(), 'Dashed' => randomScalingFactor(), 'Filled' => randomScalingFactor()],
        ['month' => 'July',      'Unfilled' => randomScalingFactor(), 'Dashed' => randomScalingFactor(), 'Filled' => randomScalingFactor()],
    ];

    \koolreport\chartjs\LineChart::create(
        array(
            'dataSource' => $data,
            'columns' => array(
                'month',
                'Unfilled' => array(
                    "backgroundColor" => 'rgb(54, 162, 235)',
                    "borderColor" => 'rgb(54, 162, 235)',
                ),
                'Dashed' => array(
                    "borderDash" => [5, 5],
                    "backgroundColor" => 'rgb(75, 192, 192)',
                    "borderColor" => 'rgb(75, 192, 192)',
                ),
                'Filled' => array(
                    "fill" => true,
                    "backgroundColor" => 'rgb(255, 99, 132)',
                    "borderColor" => 'rgb(255, 99, 132)',
                )
            ),
            "options" => array(
                "responsive" => true,
                "title" => array(
                    "display" => true,
                    "text" => "Chart.js Line Chart"
                ),
                "tooltips" => array(
                    "mode" => 'index',
                    "intersect" => false,
                ),
                "hover" => array(
                    "mode" => 'nearest',
                    "intersect" => true,
                ),
                "scales" => array(
                    "xAxes" => array(
                        array(
                            "display" => true,
                            "scaleLabel" => array(
                                "display" => true,
                                "labelString" => "Month",
                            )
                        )
                    ),
                    "yAxes" => array(
                        array(
                            "display" => true,
                            "scaleLabel" => array(
                                "display" => true,
                                "labelString" => "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