forked from matomo-org/matomo
/
TreemapVisualization.php
99 lines (88 loc) · 3.18 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?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 TreemapVisualization
*/
namespace Piwik\Plugins\TreemapVisualization;
use Piwik\Common;
/**
* @see plugins/TreemapVisualization/Treemap.php
*/
require_once PIWIK_INCLUDE_PATH . '/plugins/TreemapVisualization/Treemap.php';
/**
* Plugin that contains the Treemap DataTable visualization.
*/
class TreemapVisualization extends \Piwik\Plugin
{
/**
* The list of Actions reports for whom the treemap should have a width of 100%.
*/
private static $fullWidthActionsReports = array(
'getPageUrls',
'getEntryPageUrls',
'getExitPageUrls',
'getEntryPageTitles',
'getExitPageTitles',
'getPageTitles',
'getOutlinks',
'getDownloads',
);
/**
* @see Piwik_Plugin::getListHooksRegistered
*/
public function getListHooksRegistered()
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'AssetManager.getJsFiles' => 'getJsFiles',
'DataTableVisualization.getAvailable' => 'getAvailableDataTableVisualizations',
'ViewDataTable.configureReportView' => 'configureReportViewForActions'
);
}
public function getAvailableDataTableVisualizations(&$visualizations)
{
// treemap doesn't work w/ flat=1
if (!Common::getRequestVar('flat', 0)) {
$visualizations[] = 'Piwik\\Plugins\\TreemapVisualization\\Treemap';
}
}
public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = 'plugins/TreemapVisualization/stylesheets/treemap.less';
$stylesheets[] = 'plugins/TreemapVisualization/stylesheets/treemapColors.less';
}
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = 'libs/Jit/jit-2.0.1-yc.js';
$jsFiles[] = 'plugins/TreemapVisualization/javascripts/treemapViz.js';
}
public function configureReportViewForActions($view)
{
list($module, $method) = explode('.', $view->getReportApiMethod());
// make sure treemap is shown on actions reports
if ($module === 'Actions') {
$view->show_all_views_icons = true;
$view->show_bar_chart = false;
$view->show_pie_chart = false;
$view->show_tag_cloud = false;
if ($view->getViewDataTableId() == Treemap::ID) {
// for some actions reports, use all available space
if (in_array($method, self::$fullWidthActionsReports)) {
$view->datatable_css_class = 'infoviz-treemap-full-width';
$view->visualization_properties->max_graph_elements = 50;
} else {
$view->visualization_properties->max_graph_elements = max(10, $view->visualization_properties->max_graph_elements);
}
}
} else if ($module === 'ExampleUI'
&& $view->getViewDataTableId() == Treemap::ID
) {
$view->visualization_properties->show_evolution_values = false;
}
}
}