|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Halfpastfour\PHPChartJS\Options\Scales; |
|
4
|
|
|
|
|
5
|
|
|
use Halfpastfour\PHPChartJS\ArraySerializableInterface; |
|
6
|
|
|
use Halfpastfour\PHPChartJS\Delegate\ArraySerializable; |
|
7
|
|
|
use Halfpastfour\PHPChartJS\Delegate\NumberUtils; |
|
8
|
|
|
use Halfpastfour\PHPChartJS\Delegate\StringUtils; |
|
9
|
|
|
use JsonSerializable; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class GridLines |
|
13
|
|
|
* |
|
14
|
|
|
* @package Halfpastfour\PHPChartJS\Options\Scales |
|
15
|
|
|
*/ |
|
16
|
|
|
class GridLines implements ArraySerializableInterface, JsonSerializable |
|
17
|
|
|
{ |
|
18
|
|
|
use ArraySerializable; |
|
19
|
|
|
use StringUtils; |
|
20
|
|
|
use NumberUtils; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var bool |
|
24
|
|
|
*/ |
|
25
|
|
|
private $display; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string|string[] |
|
29
|
|
|
*/ |
|
30
|
|
|
private $color; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var float[]|null |
|
34
|
|
|
*/ |
|
35
|
|
|
private $borderDash; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var float |
|
39
|
|
|
*/ |
|
40
|
|
|
private $borderDashOffset; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var int|int[] |
|
44
|
|
|
*/ |
|
45
|
|
|
private $lineWidth; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var bool |
|
49
|
|
|
*/ |
|
50
|
|
|
private $drawBorder; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var bool |
|
54
|
|
|
*/ |
|
55
|
|
|
private $drawOnChartArea; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var bool |
|
59
|
|
|
*/ |
|
60
|
|
|
private $drawTicks; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @var int |
|
64
|
|
|
*/ |
|
65
|
|
|
private $tickMarkLength; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @var int |
|
69
|
|
|
*/ |
|
70
|
|
|
private $zeroLineWidth; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
private $zeroLineColor; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @var bool |
|
79
|
|
|
*/ |
|
80
|
|
|
private $offsetGridLines; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return bool |
|
84
|
|
|
*/ |
|
85
|
|
|
public function isDisplay() |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->display; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param bool $display |
|
92
|
|
|
* |
|
93
|
|
|
* @return $this |
|
94
|
|
|
*/ |
|
95
|
|
|
public function setDisplay($display) |
|
96
|
|
|
{ |
|
97
|
|
|
$this->display = $display; |
|
98
|
|
|
|
|
99
|
|
|
return $this; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return string|string[] |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getColor() |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->color; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param string|string[] $color |
|
112
|
|
|
* |
|
113
|
|
|
* @return $this |
|
114
|
|
|
*/ |
|
115
|
|
|
public function setColor($color) |
|
116
|
|
|
{ |
|
117
|
|
|
if (is_array($color)) { |
|
118
|
|
|
$this->color = $this->recursiveToString($color); |
|
119
|
|
|
} else { |
|
120
|
|
|
$this->color = is_null($color) ? null : strval($color); |
|
|
|
|
|
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return float[]|null |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getBorderDash() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->borderDash; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param float[] $borderDash |
|
136
|
|
|
* |
|
137
|
|
|
* @return $this |
|
138
|
|
|
*/ |
|
139
|
|
|
public function setBorderDash($borderDash) |
|
140
|
|
|
{ |
|
141
|
|
|
if (is_array($borderDash)) { |
|
|
|
|
|
|
142
|
|
|
$this->borderDash = $this->recursiveToFloat($borderDash); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
return $this; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @return float |
|
150
|
|
|
*/ |
|
151
|
|
|
public function getBorderDashOffset() |
|
152
|
|
|
{ |
|
153
|
|
|
return $this->borderDashOffset; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param float $borderDashOffset |
|
158
|
|
|
* |
|
159
|
|
|
* @return $this |
|
160
|
|
|
*/ |
|
161
|
|
|
public function setBorderDashOffset($borderDashOffset) |
|
162
|
|
|
{ |
|
163
|
|
|
$this->borderDashOffset = floatval($borderDashOffset); |
|
164
|
|
|
|
|
165
|
|
|
return $this; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @return int|int[] |
|
170
|
|
|
*/ |
|
171
|
|
|
public function getLineWidth() |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->lineWidth; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @param int|int[] $lineWidth |
|
178
|
|
|
* |
|
179
|
|
|
* @return $this |
|
180
|
|
|
*/ |
|
181
|
|
|
public function setLineWidth($lineWidth) |
|
182
|
|
|
{ |
|
183
|
|
|
if (is_array($lineWidth)) { |
|
184
|
|
|
$this->lineWidth = $this->recursiveToInt($lineWidth); |
|
185
|
|
|
} else { |
|
186
|
|
|
$this->lineWidth = is_null($lineWidth) ? null : intval($lineWidth); |
|
|
|
|
|
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @return bool |
|
194
|
|
|
*/ |
|
195
|
|
|
public function isDrawBorder() |
|
196
|
|
|
{ |
|
197
|
|
|
return $this->drawBorder; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @param bool $drawBorder |
|
202
|
|
|
* |
|
203
|
|
|
* @return $this |
|
204
|
|
|
*/ |
|
205
|
|
|
public function setDrawBorder($drawBorder) |
|
206
|
|
|
{ |
|
207
|
|
|
$this->drawBorder = boolval($drawBorder); |
|
208
|
|
|
|
|
209
|
|
|
return $this; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @return bool |
|
214
|
|
|
*/ |
|
215
|
|
|
public function isDrawOnChartArea() |
|
216
|
|
|
{ |
|
217
|
|
|
return $this->drawOnChartArea; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @param bool $drawOnChartArea |
|
222
|
|
|
* |
|
223
|
|
|
* @return $this |
|
224
|
|
|
*/ |
|
225
|
|
|
public function setDrawOnChartArea($drawOnChartArea) |
|
226
|
|
|
{ |
|
227
|
|
|
$this->drawOnChartArea = boolval($drawOnChartArea); |
|
228
|
|
|
|
|
229
|
|
|
return $this; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @return bool |
|
234
|
|
|
*/ |
|
235
|
|
|
public function isDrawTicks() |
|
236
|
|
|
{ |
|
237
|
|
|
return $this->drawTicks; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* @param bool $drawTicks |
|
242
|
|
|
* |
|
243
|
|
|
* @return $this |
|
244
|
|
|
*/ |
|
245
|
|
|
public function setDrawTicks($drawTicks) |
|
246
|
|
|
{ |
|
247
|
|
|
$this->drawTicks = boolval($drawTicks); |
|
248
|
|
|
|
|
249
|
|
|
return $this; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* @return int |
|
254
|
|
|
*/ |
|
255
|
|
|
public function getTickMarkLength() |
|
256
|
|
|
{ |
|
257
|
|
|
return $this->tickMarkLength; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* @param int $tickMarkLength |
|
262
|
|
|
* |
|
263
|
|
|
* @return $this |
|
264
|
|
|
*/ |
|
265
|
|
|
public function setTickMarkLength($tickMarkLength) |
|
266
|
|
|
{ |
|
267
|
|
|
$this->tickMarkLength = intval($tickMarkLength); |
|
268
|
|
|
|
|
269
|
|
|
return $this; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* @return int |
|
274
|
|
|
*/ |
|
275
|
|
|
public function getZeroLineWidth() |
|
276
|
|
|
{ |
|
277
|
|
|
return $this->zeroLineWidth; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* @param int $zeroLineWidth |
|
282
|
|
|
* |
|
283
|
|
|
* @return $this |
|
284
|
|
|
*/ |
|
285
|
|
|
public function setZeroLineWidth($zeroLineWidth) |
|
286
|
|
|
{ |
|
287
|
|
|
$this->zeroLineWidth = intval($zeroLineWidth); |
|
288
|
|
|
|
|
289
|
|
|
return $this; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* @return string |
|
294
|
|
|
*/ |
|
295
|
|
|
public function getZeroLineColor() |
|
296
|
|
|
{ |
|
297
|
|
|
return $this->zeroLineColor; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* @param string $zeroLineColor |
|
302
|
|
|
* |
|
303
|
|
|
* @return $this |
|
304
|
|
|
*/ |
|
305
|
|
|
public function setZeroLineColor($zeroLineColor) |
|
306
|
|
|
{ |
|
307
|
|
|
$this->zeroLineColor = is_null($zeroLineColor) ? null : strval($zeroLineColor); |
|
|
|
|
|
|
308
|
|
|
|
|
309
|
|
|
return $this; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* @return bool |
|
314
|
|
|
*/ |
|
315
|
|
|
public function isOffsetGridLines() |
|
316
|
|
|
{ |
|
317
|
|
|
return $this->offsetGridLines; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* @param bool $offsetGridLines |
|
322
|
|
|
* |
|
323
|
|
|
* @return $this |
|
324
|
|
|
*/ |
|
325
|
|
|
public function setOffsetGridLines($offsetGridLines) |
|
326
|
|
|
{ |
|
327
|
|
|
$this->offsetGridLines = boolval($offsetGridLines); |
|
328
|
|
|
|
|
329
|
|
|
return $this; |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
/** |
|
333
|
|
|
* @return array |
|
334
|
|
|
*/ |
|
335
|
|
|
public function jsonSerialize() |
|
336
|
|
|
{ |
|
337
|
|
|
return $this->getArrayCopy(); |
|
338
|
|
|
} |
|
339
|
|
|
} |
|
340
|
|
|
|