This example shows how we can make Pareto Chart.
The Pareto Chart has this definition: "A Pareto chart, named after Vilfredo Pareto, is a type of chart that contains both bars and a line graph, where individual values are represented in descending order by bars, and the cumulative total is represented by the line. ... The Pareto chart is one of the seven basic tools of quality control."
So in this example, we use CSVDataSource
to read data from data.csv
contaning category and sale column. We use the ComboChart
to create chart with both bar and line type.
The data come from the source will be sorted with Sort
process and then we create running_sale
column with AccumulativeColumn
process
$this->src('data')
->pipe(new Sort(array(
"sale"=>"desc"
)))
->pipe(new AccumulativeColumn(array(
"running_sale"=>"sale"
)))
Note: In this example, the data do not share among different widgets so we use src()
and processes directly in the chart. This is also a feature of KoolReport's widget which can receive data directly from DataSource
or Process
.
In the _runningsale we use line
as chartType. Also in the "options"
we define 2 axes and matching them with series.
"options"=>array(
"vAxes"=>array(
array("label"=>"Sale"),
array("label"=>"Running Sale"),
),
"series"=>array(
0=>array("targetAxisIndex"=>0), //"amount series"
1=>array("targetAxisIndex"=>1), //"running_total"
)
)
Enjoy the example!