1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CMEN\GoogleChartsBundle\GoogleCharts\Options; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* The explorer option allows users to pan and zoom Google charts. explorer: {} provides the default explorer behavior, |
7
|
|
|
* enabling users to pan horizontally and vertically by dragging, and to zoom in and out by scrolling. |
8
|
|
|
* This feature is experimental and may change in future releases. |
9
|
|
|
* |
10
|
|
|
* @author Christophe Meneses |
11
|
|
|
*/ |
12
|
|
|
class Explorer |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* The Google Charts explorer supports three actions : |
16
|
|
|
* dragToPan: Drag to pan around the chart horizontally and vertically. To pan only along the horizontal axis, |
17
|
|
|
* use explorer: { axis: 'horizontal' }. Similarly for the vertical axis. |
18
|
|
|
* dragToZoom: The explorer's default behavior is to zoom in and out when the user scrolls. If explorer : |
19
|
|
|
* { actions: ['dragToZoom', 'rightClickToReset'] } is used, dragging across a rectangular area zooms into |
20
|
|
|
* that area. We recommend using rightClickToReset whenever dragToZoom is used. See explorer.maxZoomIn, |
21
|
|
|
* explorer.maxZoomOut, and explorer.zoomDelta for zoom customizations. |
22
|
|
|
* rightClickToReset: Right clicking on the chart returns it to the original pan and zoom level. |
23
|
|
|
* |
24
|
|
|
* @var string[] |
25
|
|
|
*/ |
26
|
|
|
protected $actions; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* By default, users can pan both horizontally and vertically when the explorer option is used. If you want to |
30
|
|
|
* users to only pan horizontally, use explorer: { axis: 'horizontal' }. Similarly, explorer: { axis: 'vertical' } |
31
|
|
|
* enables vertical-only panning. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $axis; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* By default, users can pan all around, regardless of where the data is. To ensure that users don't pan beyond |
39
|
|
|
* the original chart, set keepInBounds true. |
40
|
|
|
* |
41
|
|
|
* @var boolean |
42
|
|
|
*/ |
43
|
|
|
protected $keepInBounds; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The maximum that the explorer can zoom in. By default, users will be able to zoom in enough that they'll see |
47
|
|
|
* only 25% of the original view. Setting explorer maxZoomIn .5 would let users zoom in only far enough to |
48
|
|
|
* see half of the original view. |
49
|
|
|
* |
50
|
|
|
* @var float |
51
|
|
|
*/ |
52
|
|
|
protected $maxZoomIn; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* The maximum that the explorer can zoom out. By default, users will be able to zoom out far enough that the |
56
|
|
|
* chart will take up only 1/4 of the available space. Setting explorer maxZoomOut 8 would let users zoom out far |
57
|
|
|
* enough that the chart would take up only 1/8 of the available space. |
58
|
|
|
* |
59
|
|
|
* @var float |
60
|
|
|
*/ |
61
|
|
|
protected $maxZoomOut; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* When users zoom in or out, explorer.zoomDelta determines how much they zoom by. The smaller the number, the |
65
|
|
|
* smoother and slower the zoom. |
66
|
|
|
* |
67
|
|
|
* @var float |
68
|
|
|
*/ |
69
|
|
|
protected $zoomDelta; |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string[] $actions |
74
|
|
|
* |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
|
|
public function setActions($actions) |
78
|
|
|
{ |
79
|
|
|
$this->actions = $actions; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $axis |
86
|
|
|
* |
87
|
|
|
* @return $this |
88
|
|
|
*/ |
89
|
|
|
public function setAxis($axis) |
90
|
|
|
{ |
91
|
|
|
$this->axis = $axis; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param boolean $keepInBounds |
98
|
|
|
* |
99
|
|
|
* @return $this |
100
|
|
|
*/ |
101
|
|
|
public function setKeepInBounds($keepInBounds) |
102
|
|
|
{ |
103
|
|
|
$this->keepInBounds = $keepInBounds; |
104
|
|
|
|
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param float $maxZoomIn |
110
|
|
|
* |
111
|
|
|
* @return $this |
112
|
|
|
*/ |
113
|
|
|
public function setMaxZoomIn($maxZoomIn) |
114
|
|
|
{ |
115
|
|
|
$this->maxZoomIn = $maxZoomIn; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param float $maxZoomOut |
122
|
|
|
* |
123
|
|
|
* @return $this |
124
|
|
|
*/ |
125
|
|
|
public function setMaxZoomOut($maxZoomOut) |
126
|
|
|
{ |
127
|
|
|
$this->maxZoomOut = $maxZoomOut; |
128
|
|
|
|
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param float $zoomDelta |
134
|
|
|
* |
135
|
|
|
* @return Explorer |
136
|
|
|
*/ |
137
|
|
|
public function setZoomDelta($zoomDelta) |
138
|
|
|
{ |
139
|
|
|
$this->zoomDelta = $zoomDelta; |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|