/**
  * Generates JSON graph data and returns it.
  *
  * @param DataTable|DataTable\Map $dataTable
  * @return string
  */
 public function generate($dataTable)
 {
     $visualization = new Chart();
     if ($dataTable->getRowsCount() > 0) {
         // if addTotalRow was called in GenerateGraphHTML, add a row containing totals of
         // different metrics
         if ($this->properties['add_total_row']) {
             $dataTable->queueFilter('AddSummaryRow', Piwik::translate('General_Total'));
         }
         $dataTable->applyQueuedFilters();
         $this->initChartObjectData($dataTable, $visualization);
     }
     return $visualization->render();
 }
Ejemplo n.º 2
0
 /**
  * Common filters for all Actions API
  *
  * @param DataTable|DataTable\Simple|DataTable\Map $dataTable
  * @param bool $expanded
  */
 protected function filterActionsDataTable($dataTable, $expanded = false)
 {
     // Must be applied before Sort in this case, since the DataTable can contain both int and strings indexes
     // (in the transition period between pre 1.2 and post 1.2 datatable structure)
     $dataTable->filter('ReplaceColumnNames');
     $dataTable->filter('Sort', array('nb_visits', 'desc', $naturalSort = false, $expanded));
     $dataTable->queueFilter('ReplaceSummaryRowLabel');
 }