diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2013-10-21 08:02:40 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2013-10-21 08:02:40 +0400 |
commit | 6a3d27b60c0946e141466d4634ae2a1e2c2f1118 (patch) | |
tree | 5b02179087a61fcd467d5071f342f7c073e68df1 /plugins/ExampleUI | |
parent | d1abe71def94d4ff60d072a8ccd1bdd2016d7634 (diff) |
refs #3994 do not create a separate class for this example
Diffstat (limited to 'plugins/ExampleUI')
-rw-r--r-- | plugins/ExampleUI/Controller.php | 19 | ||||
-rw-r--r-- | plugins/ExampleUI/CustomDataTable.php | 38 |
2 files changed, 14 insertions, 43 deletions
diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php index c059ebc89e..dc9611b57b 100644 --- a/plugins/ExampleUI/Controller.php +++ b/plugins/ExampleUI/Controller.php @@ -25,12 +25,21 @@ class Controller extends \Piwik\Plugin\Controller $controllerAction = $this->pluginName . '.' . __FUNCTION__; $apiAction = 'ExampleUI.getTemperatures'; - /** - * this is an example how you can make a custom visualization reusable. - */ - $table = new CustomDataTable(); + $view = Factory::build('table', $apiAction, $controllerAction); - echo $table->render('Temperature in °C', 'Hour of day', $apiAction, $controllerAction); + $view->config->translations['value'] = 'Temperature in °C'; + $view->config->translations['label'] = 'Hour of day'; + $view->requestConfig->filter_sort_column = 'label'; + $view->requestConfig->filter_sort_order = 'asc'; + $view->requestConfig->filter_limit = 24; + $view->config->columns_to_display = array('label', 'value'); + $view->config->y_axis_unit = '°C'; // useful if the user requests the bar graph + $view->config->show_exclude_low_population = false; + $view->config->show_table_all_columns = false; + $view->config->disable_row_evolution = true; + $view->config->max_graph_elements = 24; + + echo $view->render(); } public function evolutionGraph() diff --git a/plugins/ExampleUI/CustomDataTable.php b/plugins/ExampleUI/CustomDataTable.php deleted file mode 100644 index c7009d7c81..0000000000 --- a/plugins/ExampleUI/CustomDataTable.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Piwik - Open source web analytics - * - * @link http://piwik.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * - * @category Piwik_Plugins - * @package ExampleUI - */ - -namespace Piwik\Plugins\ExampleUI; - -use Piwik\View; -use Piwik\ViewDataTable\Factory; - -class CustomDataTable -{ - public function render($value, $label, $apiAction, $controllerAction) - { - $view = Factory::build('table', $apiAction, $controllerAction); - - $view->config->translations['value'] = $value; - $view->config->translations['label'] = $label; - $view->requestConfig->filter_sort_column = 'label'; - $view->requestConfig->filter_sort_order = 'asc'; - $view->requestConfig->filter_limit = 24; - $view->config->columns_to_display = array('label', 'value'); - $view->config->y_axis_unit = '°C'; // useful if the user requests the bar graph - $view->config->show_exclude_low_population = false; - $view->config->show_table_all_columns = false; - $view->config->disable_row_evolution = true; - $view->config->max_graph_elements = 24; - - return $view->render(); - } - -}
\ No newline at end of file |