Getting Started with KPI Table Component

Adding a KPI Table Component to the dashboard

In order to add a KPI Table component to the dashboard follow these steps:

  1. Create an instance of the KPITableComponent.
  2. Add a KPI to the table using addKPI method.
  3. Finally add the KPITableComponent instance to the dashboard..

Create an instance of KPITableComponent

$kpi = new KPITableComponent ();
$kpi->setCaption('Sales by region 2013');
$kpi->setDimensions (12, 2);

Adding Individual KPIs

In order to add individual KPI to this group use the addKPI method.

  • The first paramater is a id, this id will be used to update or delete a KPI which is described in the following sections.
  • The second paramter is a list of options.
$kpi->addKPI('firstKPI', array(
    'caption' => 'Texas',
    'value' => 2766,
    'numberPrefix' => '$'
));

Update a KPI

You can use the updateKPI method to update a specific KPI by id.

$kpi->updateKPI('firstKPI', array(
    'value' => 2391,
));

Deleting a KPI

To delete a KPI you can use the deleteKPI method by passing an id as the parameter.

$kpi->deleteKPI('firstKPI');

Setting KPI Caption color

In order to set the caption color for a specific KPI, you can use the setKPICaptionColor. This method takes two parameters:

  • The id of the KPI.
  • The color for KPI caption.
$kpi->setKPICaptionColor('firstKPI', '#006699');

Setting KPI Value Color

In order to set the value color for a specific KPI, you can use the setKPIValueColor. This method takes two parameters:

  • The id of the KPI.
  • The color for KPI value.
$kpi->setKPIValueColor('firstKPI', '#339933');

Available Options that you can set for individual KPIs

  • caption: The caption of the KPI.
  • value: The value for the KPI.
  • All options pertainiing to number formatter can be applied here. See Number Formatting.

A Complete example

<?php

class SampleDashboard extends StandaloneDashboard { public function buildDashboard(){ $kpi = new KPITableComponent ('kpi'); $kpi->setDimensions (4, 6); $kpi->setCaption('Food Units Available');

$kpi->addKPI('grains_cereals', array(
  'caption' => 'Grains/Cereals',
  'value' => 308,
  'numberSuffix' => ' units'
));
$kpi->addKPI('meat_poultry', array(
  'caption' => 'Meat/Poultry',
  'value' => 165,
  'numberSuffix' => ' units'
));
$kpi->addKPI('produce', array(
  'caption' => 'Produce',
  'value' => 100,
  'numberSuffix' => ' units'
));
$kpi->addKPI('seafood', array(
  'caption' => 'Sea Food',
  'value' => 701,
  'numberSuffix' => ' units'
));

$this->addComponent ($kpi);

} }

$db = new SampleDashboard(); $db->renderStandalone();