ClientEvents

Overview #

All charts of D3 support client events.

\koolreport\d3\ColumnChart::create(array(
    "title"=>"Sale Report",
    "dataSource"=>array(
        array("month"=>"January","sale"=>32000),
        array("month"=>"February","sale"=>43000),
        array("month"=>"March","sale"=>33000),
        array("month"=>"April","sale"=>40000),
        array("month"=>"May","sale"=>45000),
    ),
    "columns"=>array(
        "month",
        "sale"=>array(
            "label"=>"Sale Amount",
            "type"=>"number",
            "prefix"=>"$"
        ),
    ),
    "clientEvents"=>array(
        "itemSelect"=>"function(params){
            alert(params.columnName+' = '+params.selectedValue);
        }"
    )
));

Try to click on the column chart:

itemSelect #

itemSelect is an event triggered when we click on item of chart. Below are list of parameters. Note that those parameters are available or unavailable depending on chart types.

Namedescription
selectedRowIndexThe index of selected row, available in all type of charts
columnNameThe column name of selected item, not available in Pie and Donut
selectedValueThe value of selected item, available in all chart types
selectedRowContaining all data of selected rows, available in all chart types
selectedXThe x value of selected item, available in Scatter
selectedYThe y value of selected item, available in Scatter
selectedRatioThe ratio of selected item, available in Pie and Donut and FunnelChart
isSummaryColumnWhether the selected item is summary column, only available in Waterfall
selectedNameThe name of selected item, only available in Waterfall
selectedLabelThe label of selected item, only available at FunnelChart

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.