-
Notifications
You must be signed in to change notification settings - Fork 17
/
TreemapVisualization.php
61 lines (53 loc) · 1.91 KB
/
TreemapVisualization.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\TreemapVisualization;
use Piwik\Common;
use Piwik\Plugins\TreemapVisualization\Visualizations\Treemap;
/**
* Plugin that contains the Treemap DataTable visualization.
*/
class TreemapVisualization extends \Piwik\Plugin
{
public function registerEvents()
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'ViewDataTable.addViewDataTable' => 'getAvailableVisualizations', // Piwik 2.X
'ViewDataTable.filterViewDataTable' => 'removeTreemapVisualizationIfFlattenIsUsed' // Piwik 3.X
);
}
public function getAvailableVisualizations(&$visualizations)
{
// treemap doesn't work w/ flat=1
if (Common::getRequestVar('flat', 0)) {
$key = array_search('Piwik\\Plugins\\TreemapVisualization\\Visualizations\\Treemap', $visualizations);
if ($key !== false) {
unset($visualizations[$key]);
}
}
}
public function removeTreemapVisualizationIfFlattenIsUsed(&$visualizations)
{
// treemap doesn't work w/ flat=1
if (Common::getRequestVar('flat', 0) && isset($visualizations[Treemap::ID])) {
unset($visualizations[Treemap::ID]);
}
}
public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = 'plugins/TreemapVisualization/stylesheets/treemap.less';
$stylesheets[] = 'plugins/TreemapVisualization/stylesheets/treemapColors.less';
}
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = 'plugins/TreemapVisualization/libs/Jit/jit-2.0.1-yc.js';
$jsFiles[] = 'plugins/TreemapVisualization/javascripts/treemapViz.js';
}
}