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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<?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 CoreVisualizations
*/
namespace Piwik\Plugins\CoreVisualizations\Visualizations;
use Piwik\DataTable;
use Piwik\Plugins\CoreVisualizations\JqplotDataGenerator;
use Piwik\View;
use Piwik\ViewDataTable\Graph;
/**
* DataTable visualization that displays DataTable data in a JQPlot graph.
* TODO: should merge all this logic w/ jqplotdatagenerator & 'Chart' visualizations.
*/
class JqplotGraph extends Graph
{
const ID = 'jqplot_graph';
/**
* The name of the JavaScript class to use as this graph's external series toggle. The class
* must be a subclass of JQPlotExternalSeriesToggle.
*
* @see self::EXTERNAL_SERIES_TOGGLE_SHOW_ALL
*
* Default value: false
*/
const EXTERNAL_SERIES_TOGGLE = 'external_series_toggle';
/**
* Whether the graph should show all loaded series upon initial display.
*
* @see self::EXTERNAL_SERIES_TOGGLE
*
* Default value: false
*/
const EXTERNAL_SERIES_TOGGLE_SHOW_ALL = 'external_series_toggle_show_all';
/**
* The number of x-axis ticks for each x-axis label.
*
* Default: 2
*/
const X_AXIS_STEP_SIZE = 'x_axis_step_size';
public static $clientSideProperties = array(
'external_series_toggle',
'external_series_toggle_show_all'
);
public static $overridableProperties = array('x_axis_step_size');
/**
* Constructor.
*
* @param \Piwik\ViewDataTable $view
*/
public function __construct($view)
{
parent::__construct($view, $template = "@CoreVisualizations/_dataTableViz_jqplotGraph.twig");
// do not sort if sorted column was initially "label" or eg. it would make "Visits by Server time" not pretty
if ($view->filter_sort_column != 'label') {
$columns = $view->columns_to_display;
$firstColumn = reset($columns);
if ($firstColumn == 'label') {
$firstColumn = next($columns);
}
$result['filter_sort_column'] = $firstColumn;
$result['filter_sort_order'] = 'desc';
}
}
/**
* Returns an array mapping property names with default values for this visualization.
*
* @return array
*/
public static function getDefaultPropertyValues()
{
$result = parent::getDefaultPropertyValues();
return array_merge_recursive($result, array(
'show_offset_information' => false,
'show_pagination_control' => false,
'show_exclude_low_population' => false,
'show_search' => false,
'show_export_as_image_icon' => true,
'y_axis_unit' => '',
'visualization_properties' => array(
'jqplot_graph' => array(
'external_series_toggle' => false,
'external_series_toggle_show_all' => false,
'x_axis_step_size' => 2
)
)
));
}
public function getGraphData($dataTable, $properties)
{
$dataGenerator = $this->makeDataGenerator($properties);
return $dataGenerator->generate($dataTable);
}
}
require_once PIWIK_INCLUDE_PATH . '/plugins/CoreVisualizations/Visualizations/JqplotGraph/Bar.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/CoreVisualizations/Visualizations/JqplotGraph/Pie.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php';
|