public function buildDashboard() { $kpi = new KPIComponent("kpi1"); $kpi->setCaption("Hello world"); $kpi->setValue(42); $kpi->setDimensions(4, 4); $kpi->setSparkValues(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'), array(20, 32, 34, 12, 4, 16)); $this->addComponent($kpi); $table = new TableComponent('table1'); $table->setCaption("Table 1"); $table->setDimensions(6, 6); $table->addColumn('colA', "Column A"); $table->addColumn('colB', "Column B"); for ($i = 0; $i < 2; $i++) { $table->addRow(array('colA' => $i * 2, 'colB' => $i * 2 + 1)); } $this->addComponent($table); $kpi2 = new KPIComponent("kpi2"); $kpi2->setCaption("KPI 2"); $kpi2->setValue(45); $kpi2->setDimensions(4, 4); $this->addComponent($kpi2); // $chart = new ChartComponent('my_chart'); // $chart->setCaption("Chart 1"); // $chart->setDimensions(4,4); // $chart->setLabels(['January', 'February', 'March', 'April', 'May']); // $chart->addSeries("seriesA", "Series A", [1, 3, 5, 1, 9], null); // $chart->addSeries("seriesB", "Series B", [3, 1, 9, 2, 3], null); // $this->addComponent ($chart); $kpi->bindToEvent("kpiClick", array($kpi2, $table), "handleKPIClick", $this); }
public function buildDashboard() { $kpi1 = new KPIComponent("kpi1"); $kpi1->setCaption("Average Monthly Sales"); $kpi1->setDimensions(4, 2); $kpi1->setValue(513.22, array('numberPrefix' => '$')); $this->addComponent($kpi1); $kpi2 = new KPIComponent("kpi2"); $kpi2->setCaption("Average Monthly Units"); $kpi2->setDimensions(4, 2); $kpi2->setValue(22); $kpi2->setSparkValues(['Jan', "Feb", 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], [12.31, 10.34, 10.26, 9, 8.210000000000001, 13.41, 14.43, 23.31, 13.41, 11.4, 28.34, 29.21]); $this->addComponent($kpi2); }
private function fillData($id, $kpiValue, $caption, $options = array()) { $components = []; foreach ($this->dimensions as $key => $value) { $kpi = new KPIComponent("kpi" . $id . $key); $kpi->setDimensions($value[0], $value[1]); $kpi->setCaption($caption); $kpi->setValue($kpiValue); if (array_key_exists('spark', $options)) { $spark = $options['spark']; $kpi->setSparkValues($spark[0], $spark[1]); } $components[] = $kpi; } return $components; }
public function buildDashboard() { $kpi = new KPIComponent("kpi1"); $kpi->setCaption("Hello world"); $kpi->setValue(42); $kpi->setDimensions(4, 4); $kpi->setSparkValues(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'), array(20, 32, 34, 12, 4, 16)); $kpi2 = new KPIComponent("kpi2"); $kpi2->setCaption("Hello world"); $kpi2->setValue(42); $kpi2->setDimensions(4, 4); $kpi2->setSparkValues(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'), array(20, 32, 34, 12, 4, 16)); $this->log('KPI Object', "hello"); $this->log('KPI', "I am a kpi object"); $kpi->bindToEvent("kpiClick", array($kpi), "handleKPIClick", $this); $kpi2->bindToEvent("kpiClick", array($kpi2), "handleKPIClick2", $this); $this->addComponent($kpi); $this->addComponent($kpi2); }