Ejemplo n.º 1
0
 /**
  * @see ViewDataTable::main()
  * @return mixed
  */
 public function render()
 {
     // If period=range, we force the sparkline to draw daily data points
     $period = 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);
     if (empty($values)) {
         $values = array_fill(0, 30, 0);
     }
     $graph = new \Piwik\Visualization\Sparkline();
     $graph->setValues($values);
     $height = Common::getRequestVar('height', 0, 'int');
     if (!empty($height)) {
         $graph->setHeight($height);
     }
     $width = Common::getRequestVar('width', 0, 'int');
     if (!empty($width)) {
         $graph->setWidth($width);
     }
     $graph->main();
     return $graph->render();
 }
 public function onEnvironmentBootstrapped()
 {
     if (empty($_GET['ignoreClearAllViewDataTableParameters'])) {
         // TODO: should use testingEnvironment variable, not query param
         try {
             \Piwik\ViewDataTable\Manager::clearAllViewDataTableParameters();
         } catch (\Exception $ex) {
             // ignore (in case DB is not setup)
         }
     }
     if ($this->vars->optionsOverride) {
         try {
             foreach ($this->vars->optionsOverride as $name => $value) {
                 Option::set($name, $value);
             }
         } catch (\Exception $ex) {
             // ignore (in case DB is not setup)
         }
     }
     \Piwik\Plugins\CoreVisualizations\Visualizations\Cloud::$debugDisableShuffle = true;
     \Piwik\Visualization\Sparkline::$enableSparklineImages = false;
     \Piwik\Plugins\ExampleUI\API::$disableRandomness = true;
     if ($this->vars->deleteArchiveTables && !$this->vars->_archivingTablesDeleted) {
         $this->vars->_archivingTablesDeleted = true;
         DbHelper::deleteArchiveTables();
     }
 }