Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2013-10-03 02:34:18 +0400
committerThomas Steur <thomas.steur@gmail.com>2013-10-03 02:34:18 +0400
commit11d27940020c8d70c87e258227e068c54c27cb79 (patch)
treeb128a578c4947695c53bbea67010cd7c959474d5 /plugins/ExampleUI
parentf6897330a128f36c4ba658c90d593ff4b056da14 (diff)
refs #3994 added example for evolution graph
Diffstat (limited to 'plugins/ExampleUI')
-rw-r--r--plugins/ExampleUI/Controller.php25
-rw-r--r--plugins/ExampleUI/ExampleUI.php1
-rw-r--r--plugins/ExampleUI/templates/evolutiongraph.twig3
3 files changed, 20 insertions, 9 deletions
diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php
index c088aac16c..e90f6e6b49 100644
--- a/plugins/ExampleUI/Controller.php
+++ b/plugins/ExampleUI/Controller.php
@@ -11,6 +11,8 @@
namespace Piwik\Plugins\ExampleUI;
use Piwik\Common;
+use Piwik\Piwik;
+use Piwik\Site;
use Piwik\ViewDataTable;
use Piwik\View;
@@ -47,20 +49,25 @@ class Controller extends \Piwik\Controller
public function evolutionGraph()
{
- echo "<h2>Evolution of server temperatures over the last few days</h2>";
- $this->echoEvolutionGraph();
+ $view = new View('@ExampleUI/evolutiongraph');
+
+ $this->setPeriodVariablesView($view);
+ $view->evolutionGraph = $this->getEvolutionGraph(true, array('server1', 'server2'));
+
+ echo $view->render();
}
- public function echoEvolutionGraph()
+ public function getEvolutionGraph($fetch = false, array $columns = array())
{
- $view = ViewDataTable::factory(
- 'graphEvolution', 'ExampleUI.getTemperaturesEvolution', $controllerAction = 'ExampleUI.echoEvolutionGraph');
+ if (empty($columns)) {
+ $columns = Common::getRequestVar('columns');
+ $columns = Piwik::getArrayFromApiParameter($columns);
+ }
- $view->y_axis_unit = '°C'; // useful if the user requests the bar graph
- $view->translations['server1'] = "Temperature server piwik.org";
- $view->translations['server2'] = "Temperature server dev.piwik.org";
+ $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns,
+ $selectableColumns = array('server1', 'server2'), 'My documentation', 'ExampleUI.getTemperaturesEvolution');
- echo $view->render();
+ return $this->renderView($view, $fetch);
}
public function barGraph()
diff --git a/plugins/ExampleUI/ExampleUI.php b/plugins/ExampleUI/ExampleUI.php
index 2c4e1e9967..2c22bb90b7 100644
--- a/plugins/ExampleUI/ExampleUI.php
+++ b/plugins/ExampleUI/ExampleUI.php
@@ -35,6 +35,7 @@ class ExampleUI extends \Piwik\Plugin
$this->addSubMenu('Pie graph', 'pieGraph', 3);
$this->addSubMenu('Tag clouds', 'tagClouds', 4);
$this->addSubMenu('Sparklines', 'sparklines', 5);
+ $this->addSubMenu('Evolution Graph', 'evolutionGraph', 6);
}
private function addSubMenu($subMenu, $action, $order)
diff --git a/plugins/ExampleUI/templates/evolutiongraph.twig b/plugins/ExampleUI/templates/evolutiongraph.twig
new file mode 100644
index 0000000000..1aa2b10572
--- /dev/null
+++ b/plugins/ExampleUI/templates/evolutiongraph.twig
@@ -0,0 +1,3 @@
+<h2>Evolution of server temperatures over the last few days</h2>
+
+{{ evolutionGraph|raw }} \ No newline at end of file