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 a line chart with multiline labels.
For example:
labels = [['June', '2015'], 'July', 'August', 'September', 'October', 'November', 'December', ['January', '2016'], 'February', 'March', 'April', 'May']
<div id="report_render">
<?php
function randomScalingFactor()
{
return mt_rand(0, 100);
}
$data = [
['month' => ['June', '2015'], 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'July', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'August', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'September', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'October', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'November', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'December', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => ['January', '2016'], 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'February', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => ' March', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'April', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
['month' => 'May', 'My First dataset' => randomScalingFactor(), 'My Second dataset' => randomScalingFactor()],
];
\koolreport\chartjs\LineChart::create(array(
'dataSource' => $data,
'columns' => array(
"month",
"My First dataset" => array(
"fill" => false,
"backgroundColor" => 'rgb(255, 99, 132)',
"borderColor" => 'rgb(255, 99, 132)'
),
"My Second dataset" => array(
"fill" => false,
"backgroundColor" => 'rgb(54, 162, 235)',
"borderColor" => 'rgb(54, 162, 235)'
)
),
"options" => array(
"responsive" => true,
"title" => array(
"display" => true,
"text" => "Chart with Multiline Labels",
)
)
));
?>
</div>
</div>