/**
  * @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;
 }
Exemple #2
0
 /**
  * @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;
 }