Hi, I intend to create Clustered Column Chart that is able to Drill Down. How do I drill down to the specific bar (year & selected quarter)?
The code is as below
Level::create()
->widget(
KWidget::create()
->use(\koolreport\chartjs\ColumnChart::class)
->dataSource(
function($params, $scope) use ($year){
return ePNJ::rawSQL( "
SELECT
YEAR(register_date) AS tahun,
SUM(CASE WHEN QUARTER(register_date) = 1 THEN 1 ELSE 0 END) AS 'quarter1',
SUM(CASE WHEN QUARTER(register_date) = 2 THEN 1 ELSE 0 END) AS 'quarter2',
SUM(CASE WHEN QUARTER(register_date) = 3 THEN 1 ELSE 0 END) AS 'quarter3',
SUM(CASE WHEN QUARTER(register_date) = 4 THEN 1 ELSE 0 END) AS 'quarter4'
FROM student
")->run();
}
)
->columns([
"year"=>["label"=>"Year", "type"=>"string"],
"quarter1"=>array("label"=>"First Quarter", "type"=>"number"),
"quarter2"=>array("label"=>"Second Quarter", "type"=>"number"),
"quarter3"=>array("label"=>"Third Quarter", "type"=>"number"),
"quarter4"=>array("label"=>"Fourth Quarter", "type"=>"number")
])
->settings([
"tooltip"=>array("use"=>"value")
]),
Level::create()
->widget(
KWidget::create()
->use(\koolreport\chartjs\ColumnChart::class)
->dataSource(
function($params, $scope) use ($year){
return ePNJ::rawSQL(
"
SELECT
class,
COUNT(student_id) AS total
FROM student
WHERE YEAR(register_date) = '".$params["year"]."'
AND QUARTER(register_date) = ??
GROUP BY class
")->run();
}
)
->columns([
"class"=>["label"=>"Year", "type"=>"string"],
"total"=>array("label"=>"Total", "type"=>"number")
])