DualChartCard

Overview #

DualChartCard is another special type of card in which there are graphs to show below the main value. The full class name of DualChartCard is \koolreport\amazing\DualChartCard. Different of ChartCard which has only one chart, DualChartCard has two charts. The additional charts may help if you want to show two indication chart at the same time, for example, one chart showing sale amount and other showing the number of orders.

Sample Code #

<?php
\koolreport\amazing\DualChartCard::create(array(
    "title"=>"SALE",
    "infoText"=>"December 2018",
    "value"=>7000,
    "baseValue"=>8000,
    "format"=>array(
        "value"=>array(
            "prefix"=>"$"
        )
    ),
    "preset"=>"info",
    "chart"=>array(
        "dataSource"=>$this->dataStore("sale"),
        "columns"=>array(
            "month",
            "amount"=>array(
                "prefix"=>"$",
            )
        )
    ),
    "secondChart"=>array(
        "dataSource"=>$this->dataStore("sale"),
        "columns"=>array(
            "month",
            "number"
        )
    ),
    "cssClass"=>array(
        "icon"=>"fa fa-dollars"
    ),
));
?>

Properties #

Nametypedefaultdescription
titlestringThe title of the card
valuenumberThe value that you need to show
infoTextstringText under title
formatarrayContain settings for formatting the value
presetstring"primary"The preset appearance for card, accept "primary", "info", "warning", "danger"
cssClassarrayContain settings for css class
cssStylearrayContain settings for css style
chartarraySettings for chart
secondChartarraySettings for secondChart
indicatorarraySettings for indicator

Format #

There are number of settings to format the value of card:

\koolreport\amazing\DualChartCard::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:

Nametypedefaultdescription
cardstringSet extra css class for card
titlestringSet css class for title
valuestringSet css class for value
iconstringSet css class for icon

Example:

\koolreport\amazing\DualChartCard::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:

Nametypedefaultdescription
cardstringCss style for card
titlestringCss style for card title
valuestringCss style for card value
iconstringCss style for card icon

Example:

\koolreport\amazing\DualChartCard::create(array(
    "cssStyle"=>array(
        "card"=>"background-color:yellow",
        "title"=>"font-weight:bold",
        "value"=>"font-style:italic",
        "icon"=>"font-size:24px;color:#333"
    )
));

Indicator #

Nametypedefaultdescription
methodstring/functionThe method to used to calculate indicator, it accept string and anonymous function. Allow values are "percentChange", "percentComplete", "different" or custom function function($value,$baseValue){}. Inside custom function, you should return the calculated value of indicator
titlestring"Compared to {baseValue}"Title of the indicator
thresholdnumber0The positive indicator will be active if indicator value is greater than threshold

Chart settings #

The "chart" property holds important settings for the chart such as dataSource or type of chart.

Nametypedefaultdescription
dataSourceDataSource/array/functionSet extra css class for card
typestring"area"Type of chart, support "area", "line" and "column"
columnsarrayList of columns for chart and their settings

Examples #

\koolreport\amazing\DualChartCard::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:

  1. If you omit the "columns" settings, then two first columns in datasource will be used to draw charts.
  2. Your dataSource is like dataSource settings in any other widgets which you can enter array, dataStore, function, process. Please refer to here

Second Chart Settings #

The "secondChart" holds the settings for the second chart. The setting of secondChart is the same as chart settings.