/** * @see Piwik_ViewDataTable::main() */ public function main() { if ($this->mainAlreadyExecuted) { return; } $this->mainAlreadyExecuted = true; // If period=range, we force the sparkline to draw daily data points $period = Piwik_Common::getRequestVar('period'); if ($period == 'range') { $_GET['period'] = 'day'; } $this->loadDataTableFromAPI(); // then revert the hack for potentially subsequent getRequestVar $_GET['period'] = $period; $values = $this->getValuesFromDataTable($this->dataTable); $this->isDataAvailable = true; if (empty($values)) { $values = array_fill(0, 30, 0); $this->isDataAvailable = false; } $graph = new Piwik_Visualization_Sparkline(); $graph->setValues($values); $graph->main(); $this->view = $graph; }
/** * @param array $params array([src] => src url of the image) * @param bool $smarty * @return string IMG HTML tag */ function smarty_function_sparkline($params, &$smarty = false) { $src = $params['src']; $graph = new Piwik_Visualization_Sparkline(); $width = $graph->getWidth(); $height = $graph->getHeight(); return "<img class=\"sparkline\" alt=\"\" src=\"{$src}\" width=\"{$width}\" height=\"{$height}\" />"; }
/** * @param string $url * @return string IMG HTML tag */ function smarty_function_sparkline($params, &$smarty = false) { $src = $params['src']; $width = Piwik_Visualization_Sparkline::getWidth(); $height = Piwik_Visualization_Sparkline::getHeight(); return "<img class=\"sparkline\" alt=\"\" src=\"$src\" width=\"$width\" height=\"$height\" />"; }
/** * @see Piwik_ViewDataTable::main() */ public function main() { if ($this->mainAlreadyExecuted) { return; } $this->mainAlreadyExecuted = true; $this->loadDataTableFromAPI(); $this->isDataAvailable = $this->dataTable->getRowsCount() != 0; if (!$this->isDataAvailable) { throw new Exception(Piwik_Translate('General_NoDataForGraph')); } $values = $this->getValuesFromDataTable($this->dataTable); $graph = new Piwik_Visualization_Sparkline(); $graph->setValues($values); $graph->main(); $this->view = $graph; }
/** * @see Piwik_ViewDataTable::main() */ public function main() { if ($this->mainAlreadyExecuted) { return; } $this->mainAlreadyExecuted = true; // we load the data with the filters applied $this->loadDataTableFromAPI(); $this->dataAvailable = $this->dataTable->getRowsCount() != 0; if (!$this->dataAvailable) { throw new Exception("No data for this graph"); } else { $data = $this->generateDataFromDataTableArray($this->dataTable); $graph = new Piwik_Visualization_Sparkline(); $graph->setData($data); $graph->main(); // var_dump($data);exit; $this->view = $graph; } }