ChartCard
Overview #
ChartCard
is another special type of card in which there is graph to show below the main value. The full class name of ChartCard is \koolreport\amazing\ChartCard
.
Sample Code #
<?php
\koolreport\amazing\ChartCard::create(array(
"title"=>"Member Online",
"value"=>56000,
"preset"=>"primary",
"chart"=>array(
"dataSource"=>$this->dataStore("online_by_day),
),
"cssClass"=>array(
"icon"=>"icon-people"
)
));
?>
Properties #
Name | type | default | description |
---|---|---|---|
title | string | The title of the card | |
value | number | The value that you need to show | |
format | array | Contain settings for formatting the value | |
preset | string | "primary" | The preset appearance for card, accept "primary" , "info" , "warning" , "danger" |
cssClass | array | Contain settings for css class | |
cssStyle | array | Contain settings for css style | |
chart | array | Settings for chart | |
href | string/function | Set an url or an action for card when it is clicked |
Format #
There are number of settings to format the value
of card:
\koolreport\amazing\ChartCard::create(array(
...
"format"=>array(
"value"=>array(
"decimals"=>2, // Number of decimals to show
"decimalPoint"=>".", // Decimal point character
"thounsandSeparator"=>",", // Thousand separator
"prefix"=>"$", // Prefix
"suffix"=>"USD" // Suffix
)
)
))
cssClass #
There are number of sub settings for cssClass:
Name | type | default | description |
---|---|---|---|
card | string | Set extra css class for card | |
title | string | Set css class for title | |
value | string | Set css class for value | |
icon | string | Set css class for icon |
Example:
\koolreport\amazing\ChartCard::create(array(
"cssClass"=>array(
"card"=>"my-own-card-class",
"tittle"=>"font-bold",
"value"=>"big-font",
"icon"=>"fa fa-dollar"
)
));
Notice: The "icon"
property can be used to set the icon using font-awesome or simpleline icon.
cssStyle #
Alternative to set the cssClass
, you may directly set the css style to the card element:
Name | type | default | description |
---|---|---|---|
card | string | Css style for card | |
title | string | Css style for card title | |
value | string | Css style for card value | |
icon | string | Css style for card icon |
Example:
\koolreport\amazing\ChartCard::create(array(
"cssStyle"=>array(
"card"=>"background-color:yellow",
"title"=>"font-weight:bold",
"value"=>"font-style:italic",
"icon"=>"font-size:24px;color:#333"
)
));
Chart settings #
The "chart"
property holds important settings for the chart such as dataSource
or type
of chart.
Name | type | default | description |
---|---|---|---|
dataSource | DataSource/array/function | Set extra css class for card | |
type | string | "area" | Type of chart, support "area" , "line" and "column" |
columns | array | List of columns for chart and their settings |
Examples #
\koolreport\amazing\ChartCard::create(array(
"chart"=>array(
"type"=>"area",
"dataSource"=>$this->dataStore("orders"),
"columns"=>array(
"date",
"amount"=>array(
"type"=>"number"
"decimals"=>2, // Number of decimals to show
"decimalPoint"=>".", // Decimal point character
"thounsandSeparator"=>",", // Thousand separator
"prefix"=>"$", // Prefix
"suffix"=>"USD" // Suffix
)
)
)
));
Note:
- If you omit the
"columns"
settings, then two first columns in datasource will be used to draw charts. - Your
dataSource
is like dataSource settings in any other widgets which you can enter array, dataStore, function, process. Please refer to here
href #
Set a url link #
The same as you set href
in an <a>
element in html, you may set "href"
property for the ChartCard
so that users will be directed to new url location when they click the card. This is extremely useful when you want to show details of data to user after view the summarization on card.
ChartCard::create(array(
"href"=>"http://example.com/defails"
));
Set a javascript function #
ChartCard::create(array(
"href"=>"function(){
alert('click on card');
}"
));
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.