I am sorry for my late reply. We was busy to code some of cool features for next version.
Here is what you can do:
In the setup()
function of report
$this->src("your_data_source")
->query("
SELECT
sum(Total_number_of_06_month_children) AS total_child,
sum(Number_of_Referrals_for_SAM_under_6_Month) AS number_of_ref
FROM
zform_352
")
->pipe(new ColumnMeta(array(
"total_child"=>array(
"label"=>"Total Child",
),
"number_of_ref"=>array(
"label"=>"Number of Reference"
)
)))
->pipe(new Transpose())
->pipe(new ColumnMeta(array(
"c0"=>array(
"name"=>"category",
"label"=>"Category",
),
"c1"=>array(
"name"=>"quantity",
"label"=>"Quantity"
)
)))
->pipe($this->dataStore("result_0_6_months"));
Draw chart on the report view:
<?php
ColumnChart::create(array(
"dataStore"=>$this->dataStore("result_0_6_months"),
));
?>
Let me explain a little for the steps you take on the setup()
function:
- First you get data in form of table which have total_child and number_of_ref as columns.
- You set the label for total_child as "Total Child" and number_of_ref as "Number of Reference" using
ColumnMeta
.
- Important: Using the
Transpose
process to transform the columns into rows.
- Change the name of columns from "c0" to "category" and "c1" to "quantity".
The format of table before step 3 will look like this:
total_child | number_of_ref |
500 | 200 |
The format of table after step 3 will look like this:
c0 | c1 |
Total Child | 500 |
Number of Reference | 200 |
Using the Transpose
process, you will bring data table to the format that can be visualized by Google ColumnChart.
Hope that my answer helps.
Let us know if you need any further assistance.
Regards,
KoolPHP Inc