protected function buildView() { $view = new Piwik_View($this->dataTableTemplate); if (!$this->isDataAvailable) { $view->cloudValues = array(); } else { $columnToDisplay = $this->getColumnToDisplay(); $columnTranslation = $this->getColumnTranslation($columnToDisplay); $values = $this->dataTable->getColumn($columnToDisplay); $labels = $this->dataTable->getColumn('label'); $labelMetadata = array(); foreach ($this->dataTable->getRows() as $row) { $logo = false; if ($this->displayLogoInsteadOfLabel) { $logo = $row->getMetadata('logo'); } $labelMetadata[$row->getColumn('label')] = array('logo' => $logo, 'url' => $row->getMetadata('url')); } $cloud = new Piwik_Visualization_Cloud(); foreach ($labels as $i => $label) { $cloud->addWord($label, $values[$i]); } $cloudValues = $cloud->render('array'); foreach ($cloudValues as &$value) { $value['logoWidth'] = round(max(16, $value['percent'])); } $view->columnTranslation = $columnTranslation; $view->labelMetadata = $labelMetadata; $view->cloudValues = $cloudValues; } $view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet(); $view->properties = $this->getViewProperties(); return $view; }
protected function buildView() { $view = new Piwik_View($this->dataTableTemplate); if (!$this->isDataAvailable) { $view->cloudValues = array(); } else { $columnToDisplay = $this->getColumnToDisplay(); $columnTranslation = $this->getColumnTranslation($columnToDisplay); $values = $this->dataTable->getColumn($columnToDisplay); $labels = $this->dataTable->getColumn('label'); $labelMetadata = array(); foreach ($this->dataTable->getRows() as $row) { $logo = false; if ($this->displayLogoInsteadOfLabel) { $logo = $row->getMetadata('logo'); } $labelMetadata[$row->getColumn('label')] = array('logo' => $logo, 'url' => $row->getMetadata('url')); } $cloud = new Piwik_Visualization_Cloud(); foreach ($labels as $i => $label) { $cloud->addWord($label, $values[$i]); } $cloudValues = $cloud->render('array'); foreach ($cloudValues as &$value) { $value['logoWidth'] = round(max(16, $value['percent'])); } $view->columnTranslation = $columnTranslation; $view->labelMetadata = $labelMetadata; $view->cloudValues = $cloudValues; } $view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet(); $view->properties = $this->getViewProperties(); $view->reportDocumentation = $this->getReportDocumentation(); // if it's likely that the report data for this data table has been purged, // set whether we should display a message to that effect. $view->showReportDataWasPurgedMessage = $this->hasReportBeenPurged(); $view->deleteReportsOlderThan = Piwik_GetOption('delete_reports_older_than'); return $view; }