LegacyDrillDown
Overview #
Note: LegacyDrillDown
is the old DrillDown Widget. If you have used the old drilldown report, rename the class to LegacyDrillDown
.
LegacyDrillDown
is an widget that allows you to setup an drill-down report in fastest and easiest way. All you need to do are:
- Setup SQL Statement to withdraw data
- Setup multi-levels of drill-down.
- On each level of drill-down, choose chart type to visualize data
Example #
<?php
LegacyDrillDown::create(array(
"name"=>"saleReportByLocation",
"title"=>"Sale By Location",
//Define dataSource which is SQL statement to load all table
"dataSource"=>(
$this->src("mydata")->query("SELECT country, state, city, sale_amount FROM orders")
),
//What we want to calculate
"calculate"=>array(
"sum"=>"sale_amount"
),
"levels"=>array(
//Level 1: Group all table by country, showing all countries with `sale_amount` by country.
array(
"groupBy"=>"country",
"widget"=>array(ColumnChart::class,array(
"columns"=>array("country","sale_amount")
))
"title"=>"All countries",
),
//Level 2: When user select a country, the widget shows `sale_amount` by state of that country
array(
"groupBy"=>"state",
"widget"=>array(ColumnChart::class,array(
"columns"=>array("state","sale_amount")
)),
"title"=>function($params)
{
return $params["country"];
}
),
//Level 3: When user continues to select a state, then widget will show `sale_amount` by city of that state
array(
"groupBy"=>"city",
"widget"=>array(Table::class,array(
"columns"=>array("city","sale_amount")
)),
"title"=>function($params)
{
return $params["city"];
}
)
)
));
?>
Properties #
name | type | default | description |
---|---|---|---|
name | string | *Required Name of the drill down report | |
dataSource | mixed | *Required DataSource accepts data in form of DataStore, array, or even process. | |
dataStore | mixed | This can be used alternatively to dataSource | |
calculate | array | *Required Define what we want to summarize in form of "{method}"=>"{columnName}" . The method supports "sum" , "avg" , "min" , "max" | |
levels | array | * Required List of all levels for drill down report. See the level properties for more detail of settings on each level. | |
showLevelTitle | bool | true | Whether title of each level is shown |
btnBack | mixed | true | By default, the button Back will shown, give it value false you will off the Back button. This property can receive array() to customize cssClass and text of button "btnBack"=>array("text"=>"Go Back","class"=>"btn btn-default btn-warning") |
css | mixed | Defined css for the most important elements in the widgets, see the $css properties for more details. | |
panelStyle | string | "default" | Set the panel style, accept value "default" , "danger" , "success" , "info" |
title | string | Title that is showed on top of drill-down report. | |
scope | array/function | Set the group of parameters which will be kept persistent during the ajax post back of drill-down. | |
clientEvents | array | Register client-event, see client-event for more details. |
Css Properties #
name | type | default | description |
---|---|---|---|
panel | string | Define css style for top panel | |
levelTitle | string | Define css style for section that holds titles of level | |
btnBack | string | Add css style for Back button | |
body | string | Defined css style for body |
Examples
<?php
LegacyDrillDown::create(array(
...
"css"=>array(
"btnBack"=>"font-style:italic";
"body"=>"height:300px;"
)
));
?>
Level properties #
As we have seen from example on the top of page, levels
property is an array of each level. Before are the settings of a level
name | type | default | description |
---|---|---|---|
groupBy | string | *Required contain the column name which drill down will group by on each level | |
title | string, function | Set the title information for each level, it accepts static string or a function to generate dynamic title for level. The function will receive a parameter as array containing all previous selection of users | |
widget | array | Contain the class name of widget that you want to use and its settings. You may use virtually all kind of widgets here. It could be Table or GoogleChart or any kinds of widgets available for KoolReport. Please see example of top for more details. |
Client events #
LegacyDrillDown
support following events:
name | description |
---|---|
nexting | Fired when drill-down is preparing to go to next level. Return false to cancel action. |
nexted | Fired when drill-down went to next level successfully. |
backing | Fired when drill-down is going to go back to previous level. Return false to cancel action. |
backed | Fired when drill-down went back to previous level |
changed | Fired when drill-down changed level |
Example
<?php
LegacyDrillDown::create(array(
...
"clientEvents"=>array(
"nexting"=>"function(params){
return false;//Cancel action
}",
"nexted"=>"function(params){
console.log('Nexted to'+params.level);
}",
);
));
?>
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.