1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CMEN\GoogleChartsBundle\GoogleCharts\Options; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @author Christophe Meneses |
7
|
|
|
*/ |
8
|
|
|
class VAxis |
9
|
|
|
{ |
10
|
|
|
use TitleTrait; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* vAxis property that specifies the baseline for the vertical axis. If the baseline is larger than the highest |
14
|
|
|
* grid line or smaller than the lowest grid line, it will be rounded to the closest gridline. |
15
|
|
|
* |
16
|
|
|
* @var int |
17
|
|
|
*/ |
18
|
|
|
protected $baseline; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Specifies the color of the baseline for the vertical axis. Can be any HTML color string, |
22
|
|
|
* for example: 'red' or '#00cc00'. |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $baselineColor; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The direction in which the values along the vertical axis grow. Specify -1 to reverse the order of the values. |
30
|
|
|
* Default : 1. |
31
|
|
|
* |
32
|
|
|
* @var int |
33
|
|
|
*/ |
34
|
|
|
protected $direction; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* A format string for numeric axis labels. This is a subset of the ICU pattern set . For instance, |
38
|
|
|
* '#,###%' will display values "1,000%", "750%", and "50%" for values 10, 7.5, and 0.5. You can also |
39
|
|
|
* supply any of the following : |
40
|
|
|
* 'none' : displays numbers with no formatting (e.g., 8000000) |
41
|
|
|
* 'decimal' : displays numbers with thousands separators (e.g., 8,000,000) |
42
|
|
|
* 'scientific' : displays numbers in scientific notation (e.g., 8e6) |
43
|
|
|
* 'currency' : displays numbers in the local currency (e.g., $8,000,000.00) |
44
|
|
|
* 'percent' : displays numbers as percentages (e.g., 800,000,000%) |
45
|
|
|
* 'short' : displays abbreviated numbers (e.g., 8M) |
46
|
|
|
* 'long' : displays numbers as full words (e.g., 8 million). |
47
|
|
|
* |
48
|
|
|
* The actual formatting applied to the label is derived from the locale the API has been loaded with. |
49
|
|
|
* For more details, see loading charts with a specific locale. |
50
|
|
|
* |
51
|
|
|
* @var string |
52
|
|
|
*/ |
53
|
|
|
protected $format; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var Gridlines |
57
|
|
|
*/ |
58
|
|
|
protected $gridlines; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var MinorGridlines |
62
|
|
|
*/ |
63
|
|
|
protected $minorGridlines; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* If true, makes the vertical axis a logarithmic scale. Note : All values must be positive. |
67
|
|
|
* |
68
|
|
|
* @var bool |
69
|
|
|
*/ |
70
|
|
|
protected $logScale; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* vAxis property that makes the vertical axis a logarithmic scale. Can be one of the following:. |
74
|
|
|
* |
75
|
|
|
* - null : No logarithmic scaling is performed. |
76
|
|
|
* - 'log' : Logarithmic scaling. Negative and zero values are not plotted. This option is the same as setting |
77
|
|
|
* hAxis: { logscale: true }. |
78
|
|
|
* - 'mirrorLog' : Logarithmic scaling in which negative and zero values are plotted. The plotted value of a |
79
|
|
|
* negative number is the negative of the log of the absolute value. Values close to 0 are plotted on a |
80
|
|
|
* linear scale. |
81
|
|
|
* |
82
|
|
|
* This option is only supported for a continuous axis. |
83
|
|
|
* |
84
|
|
|
* @var string |
85
|
|
|
*/ |
86
|
|
|
protected $scaleType; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Position of the vertical axis text, relative to the chart area. Supported values: 'out', 'in', 'none'. |
90
|
|
|
* |
91
|
|
|
* @var string |
92
|
|
|
*/ |
93
|
|
|
protected $textPosition; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @var MediumTextStyle |
97
|
|
|
*/ |
98
|
|
|
protected $textStyle; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Replaces the automatically generated Y-axis ticks with the specified array. Each element of the array should |
102
|
|
|
* be either a valid tick value (such as a number, date, datetime, or timeofday), or an array. If it's an array, |
103
|
|
|
* it should have a v property for the tick value, and an optional f property containing the literal string to be |
104
|
|
|
* displayed as the label. Examples : |
105
|
|
|
* [5,10,15,20] |
106
|
|
|
* [ ['v' => 32, 'f' => 'thirty two'], ['v' => 64, 'f' => 'sixty four'] ] ] |
107
|
|
|
* [16, ['v' => 32, 'f' => 'thirty two'], ['v' => 64, 'f' => 'sixty four'], 128] ]. |
108
|
|
|
* |
109
|
|
|
* @var array<mixed> |
110
|
|
|
*/ |
111
|
|
|
protected $ticks; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @var TitleTextStyle |
115
|
|
|
*/ |
116
|
|
|
protected $titleTextStyle; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Moves the max value of the vertical axis to the specified value; this will be upward in most charts. |
120
|
|
|
* Ignored if this is set to a value smaller than the maximum y-value of the data. vAxis.viewWindow.max |
121
|
|
|
* overrides this property. |
122
|
|
|
* |
123
|
|
|
* @var int |
124
|
|
|
*/ |
125
|
|
|
protected $maxValue; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Moves the min value of the vertical axis to the specified value; this will be downward in most charts. |
129
|
|
|
* Ignored if this is set to a value greater than the minimum y-value of the data. vAxis.viewWindow.min |
130
|
|
|
* overrides this property. |
131
|
|
|
* |
132
|
|
|
* @var int |
133
|
|
|
*/ |
134
|
|
|
protected $minValue; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Specifies how to scale the vertical axis to render the values within the chart area. The following string |
138
|
|
|
* values are supported: |
139
|
|
|
* 'pretty' - Scale the vertical values so that the maximum and minimum data values are rendered a bit inside the |
140
|
|
|
* top and bottom of the chart area. This will cause vaxis.viewWindow.min and vaxis.viewWindow.max to be ignored. |
141
|
|
|
* 'maximized' - Scale the vertical values so that the maximum and minimum data values touch the top and bottom |
142
|
|
|
* of the chart area. This will cause vaxis.viewWindow.min and vaxis.viewWindow.max to be ignored. |
143
|
|
|
* 'explicit' - A deprecated option for specifying the top and bottom scale values of the chart area. |
144
|
|
|
* (Deprecated because it's redundant with vaxis.viewWindow.min and vaxis.viewWindow.max. Data values outside |
145
|
|
|
* these values will be cropped. You must specify a vAxis.viewWindow object describing the maximum and minimum |
146
|
|
|
* values to show. |
147
|
|
|
* |
148
|
|
|
* @var string |
149
|
|
|
*/ |
150
|
|
|
protected $viewWindowMode; |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @var ViewWindow |
154
|
|
|
*/ |
155
|
|
|
protected $viewWindow; |
156
|
|
|
|
157
|
11 |
|
public function __construct() |
158
|
|
|
{ |
159
|
11 |
|
$this->gridlines = new Gridlines(); |
160
|
11 |
|
$this->minorGridlines = new MinorGridlines(); |
161
|
11 |
|
$this->titleTextStyle = new TitleTextStyle(); |
162
|
11 |
|
$this->viewWindow = new ViewWindow(); |
163
|
11 |
|
$this->textStyle = new MediumTextStyle(); |
164
|
|
|
} |
165
|
|
|
|
166
|
2 |
|
public function getGridlines(): Gridlines |
167
|
|
|
{ |
168
|
2 |
|
return $this->gridlines; |
169
|
|
|
} |
170
|
|
|
|
171
|
2 |
|
public function getMinorGridlines(): MinorGridlines |
172
|
|
|
{ |
173
|
2 |
|
return $this->minorGridlines; |
174
|
|
|
} |
175
|
|
|
|
176
|
2 |
|
public function getTitleTextStyle(): TitleTextStyle |
177
|
|
|
{ |
178
|
2 |
|
return $this->titleTextStyle; |
179
|
|
|
} |
180
|
|
|
|
181
|
2 |
|
public function getViewWindow(): ViewWindow |
182
|
|
|
{ |
183
|
2 |
|
return $this->viewWindow; |
184
|
|
|
} |
185
|
|
|
|
186
|
2 |
|
public function getTextStyle(): MediumTextStyle |
187
|
|
|
{ |
188
|
2 |
|
return $this->textStyle; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return $this |
193
|
|
|
*/ |
194
|
2 |
|
public function setBaseline(int $baseline) |
195
|
|
|
{ |
196
|
2 |
|
$this->baseline = $baseline; |
197
|
|
|
|
198
|
2 |
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return $this |
203
|
|
|
*/ |
204
|
2 |
|
public function setBaselineColor(string $baselineColor) |
205
|
|
|
{ |
206
|
2 |
|
$this->baselineColor = $baselineColor; |
207
|
|
|
|
208
|
2 |
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @return $this |
213
|
|
|
*/ |
214
|
2 |
|
public function setDirection(int $direction) |
215
|
|
|
{ |
216
|
2 |
|
$this->direction = $direction; |
217
|
|
|
|
218
|
2 |
|
return $this; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @return $this |
223
|
|
|
*/ |
224
|
2 |
|
public function setFormat(string $format) |
225
|
|
|
{ |
226
|
2 |
|
$this->format = $format; |
227
|
|
|
|
228
|
2 |
|
return $this; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @return $this |
233
|
|
|
*/ |
234
|
2 |
|
public function setLogScale(bool $logScale) |
235
|
|
|
{ |
236
|
2 |
|
$this->logScale = $logScale; |
237
|
|
|
|
238
|
2 |
|
return $this; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @return $this |
243
|
|
|
*/ |
244
|
2 |
|
public function setScaleType(string $scaleType) |
245
|
|
|
{ |
246
|
2 |
|
$this->scaleType = $scaleType; |
247
|
|
|
|
248
|
2 |
|
return $this; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @return $this |
253
|
|
|
*/ |
254
|
2 |
|
public function setTextPosition(string $textPosition) |
255
|
|
|
{ |
256
|
2 |
|
$this->textPosition = $textPosition; |
257
|
|
|
|
258
|
2 |
|
return $this; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @param array<mixed> $ticks |
263
|
|
|
* |
264
|
|
|
* @return $this |
265
|
|
|
*/ |
266
|
2 |
|
public function setTicks(array $ticks) |
267
|
|
|
{ |
268
|
2 |
|
$this->ticks = $ticks; |
269
|
|
|
|
270
|
2 |
|
return $this; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @return $this |
275
|
|
|
*/ |
276
|
2 |
|
public function setMaxValue(int $maxValue) |
277
|
|
|
{ |
278
|
2 |
|
$this->maxValue = $maxValue; |
279
|
|
|
|
280
|
2 |
|
return $this; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @return $this |
285
|
|
|
*/ |
286
|
2 |
|
public function setMinValue(int $minValue) |
287
|
|
|
{ |
288
|
2 |
|
$this->minValue = $minValue; |
289
|
|
|
|
290
|
2 |
|
return $this; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* @return $this |
295
|
|
|
*/ |
296
|
2 |
|
public function setViewWindowMode(string $viewWindowMode) |
297
|
|
|
{ |
298
|
2 |
|
$this->viewWindowMode = $viewWindowMode; |
299
|
|
|
|
300
|
2 |
|
return $this; |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
|