ProgressCard

Overview #

ProgressCard is a beautiful card useful to show the progress or percent of completion compared to the goal.

Sample Code #

<?php
\koolreport\amazing\ProgressCard::create(array(
    "title"=>"April 2018",
    "infoText"=>"The sale on April 2018 has completed {indicatorValue} of revenue target.",
    "value"=>7500,
    "preset"=>"info",
    "baseValue"=>10000,
    "format"=>array(
        "value"=>array(
            "prefix"=>"$"
        ),
        "indicator"=>array(
            "decimals"=>0
        )
    ),
    "cssClass"=>array(
        "icon"=>"fa fa-euro"
    ),
));
?>

Properties #

Nametypedefaultdescription
titlestringThe title of the card
infoTextstringThe title of the card
valuenumberThe value that you need to show
baseValuenumberThe base value used to calculate indicator
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
indicatorarraySettings for indicator
hrefstring/functionSet an url or an action for card when it is clicked

Format #

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

ProgressCard::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
        ),
        "indicator"=>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
infoTextstringCss class for card infoText
valuestringSet css class for value
iconstringSet css class for icon
progressstringSet css class for progress bar

Example:

ProgressCard::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
infoTextstringCss style for card infoText
valuestringCss style for card value
iconstringCss style for card icon
progressstringSet css style for progress bar

Example:

    <?php
    \koolreport\amazing\ProgressCard::create(array(
        "title"=>"April 2018",
        "infoText"=>"The sale on April 2018 has completed {indicatorValue} of revenue target.",
        "value"=>7500,
        "preset"=>"info",
        "baseValue"=>10000,
        "format"=>array(
            "value"=>array(
                "prefix"=>"$"
            ),
            "indicator"=>array(
                "decimals"=>0
            )
        ),
        "cssClass"=>array(
            "icon"=>"fa fa-euro"
        ),
    ));
    ?>

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

Example:

ProgressCard::create(array(
    "indicator"=>array(
        "method"=>"perentChange",
        "title"=>"Compared to {baseValue}",
        "threshold"=>50,
    )
));
ProgressCard::create(array(
    "indicator"=>array(
        "method"=>function($value,$baseValue){
            return ($value-$baseValue)*100/$baseValue;
        },
    )
));

href #

The same as you set href in an <a> element in html, you may set "href" property for the ProgressCard 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.

ProgressCard::create(array(
    "href"=>"http://example.com/defails"
));

Set a javascript function #

ProgressCard::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.