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 non numeric Y axis.
For example:
yLabels = ['', 'Request Added', 'Request Viewed', 'Request Accepted', 'Request Solved', 'Solving Confirmed'],
<?php
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">
<?php
$yLabels = ['', 'Request Added', 'Request Viewed', 'Request Accepted', 'Request Solved', 'Solving Confirmed'];
$data = [
['xLabels' => 'January', 'My First dataset' => ''],
['xLabels' => 'February', 'My First dataset' => 'Request Added'],
['xLabels' => 'March', 'My First dataset' => 'Request Added'],
['xLabels' => 'April', 'My First dataset' => 'Request Added'],
['xLabels' => 'May', 'My First dataset' => 'Request Viewed'],
['xLabels' => 'June', 'My First dataset' => 'Request Viewed'],
['xLabels' => 'July', 'My First dataset' => 'Request Viewed']
];
\koolreport\chartjs\LineChart::create(array(
'dataSource' => $data,
'columns' => array(
"xLabels",
"My First dataset" => array(
"fill" => false,
"backgroundColor" => 'rgb(255, 99, 132)',
"borderColor" => 'rgb(255, 99, 132)'
)
),
"options" => array(
"responsive" => true,
"title" => array(
"display" => true,
"text" => 'Chart with Non Numeric Y Axis'
),
"scales" => array(
"xAxes" => array(
array(
"display" => true,
"scaleLabel" => array(
"display" => true,
"labelString" => 'Month'
)
)
),
"yAxes" => array(
array(
"type" => 'category',
"labels" => $yLabels,
"position" => 'left',
"display" => true,
"scaleLabel" => array(
"display" => true,
"labelString" => 'Request State'
),
"ticks" => array(
"reverse" => true,
)
)
)
)
)
));
?>
</div>