1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the highcharts-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\HighchartsBundle\API\Chart; |
13
|
|
|
|
14
|
|
|
use JsonSerializable; |
15
|
|
|
use WBW\Library\Core\Utility\Argument\ArrayUtility; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Highcharts series. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\HighchartsBundle\API\Chart |
22
|
|
|
* @version 5.0.14 |
23
|
|
|
* @final |
24
|
|
|
*/ |
25
|
|
|
final class HighchartsSeries implements JsonSerializable { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Data. |
29
|
|
|
* |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
private $data; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Data parser. |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
* @deprecated |
39
|
|
|
*/ |
40
|
|
|
private $dataParser; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Data URL. |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
* @deprecated |
47
|
|
|
*/ |
48
|
|
|
private $dataURL; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Id. |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
* @since 1.2.0 |
55
|
|
|
*/ |
56
|
|
|
private $id; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Index. |
60
|
|
|
* |
61
|
|
|
* @var integer |
62
|
|
|
* @since 2.3.0 |
63
|
|
|
*/ |
64
|
|
|
private $index; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Legend index. |
68
|
|
|
* |
69
|
|
|
* @var integer |
70
|
|
|
*/ |
71
|
|
|
private $legendIndex; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Name. |
75
|
|
|
* |
76
|
|
|
* @var string |
77
|
|
|
*/ |
78
|
|
|
private $name; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Stack. |
82
|
|
|
* |
83
|
|
|
* @var string |
84
|
|
|
* @since 2.1 |
85
|
|
|
*/ |
86
|
|
|
private $stack; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Type. |
90
|
|
|
* |
91
|
|
|
* @var string |
92
|
|
|
*/ |
93
|
|
|
private $type; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* X axis. |
97
|
|
|
* |
98
|
|
|
* @var integer|string |
99
|
|
|
*/ |
100
|
|
|
private $xAxis = "0"; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Y axis. |
104
|
|
|
* |
105
|
|
|
* @var integer|string |
106
|
|
|
*/ |
107
|
|
|
private $yAxis = "0"; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Z index. |
111
|
|
|
* |
112
|
|
|
* @var integer |
113
|
|
|
*/ |
114
|
|
|
private $zIndex; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Constructor. |
118
|
|
|
* |
119
|
|
|
* @param boolean $ignoreDefaultValues Ignore the default values. |
120
|
|
|
*/ |
121
|
|
|
public function __construct($ignoreDefaultValues = true) { |
122
|
|
|
if (true === $ignoreDefaultValues) { |
123
|
|
|
$this->clear(); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Clear. |
129
|
|
|
* |
130
|
|
|
* @return void |
131
|
|
|
*/ |
132
|
|
|
public function clear() { |
133
|
|
|
|
134
|
|
|
// Clear the data. |
135
|
|
|
$this->data = null; |
|
|
|
|
136
|
|
|
|
137
|
|
|
// Clear the data parser. |
138
|
|
|
$this->dataParser = null; |
|
|
|
|
139
|
|
|
|
140
|
|
|
// Clear the data URL. |
141
|
|
|
$this->dataURL = null; |
|
|
|
|
142
|
|
|
|
143
|
|
|
// Clear the id. |
144
|
|
|
$this->id = null; |
145
|
|
|
|
146
|
|
|
// Clear the index. |
147
|
|
|
$this->index = null; |
148
|
|
|
|
149
|
|
|
// Clear the legend index. |
150
|
|
|
$this->legendIndex = null; |
151
|
|
|
|
152
|
|
|
// Clear the name. |
153
|
|
|
$this->name = null; |
154
|
|
|
|
155
|
|
|
// Clear the stack. |
156
|
|
|
$this->stack = null; |
157
|
|
|
|
158
|
|
|
// Clear the type. |
159
|
|
|
$this->type = null; |
160
|
|
|
|
161
|
|
|
// Clear the x axis. |
162
|
|
|
$this->xAxis = null; |
163
|
|
|
|
164
|
|
|
// Clear the y axis. |
165
|
|
|
$this->yAxis = null; |
166
|
|
|
|
167
|
|
|
// Clear the z index. |
168
|
|
|
$this->zIndex = null; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Get the data. |
173
|
|
|
* |
174
|
|
|
* @return array Returns the data. |
175
|
|
|
*/ |
176
|
|
|
public function getData() { |
177
|
|
|
return $this->data; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Get the data parser. |
182
|
|
|
* |
183
|
|
|
* @return string Returns the data parser. |
184
|
|
|
* @deprecated |
185
|
|
|
*/ |
186
|
|
|
public function getDataParser() { |
187
|
|
|
return $this->dataParser; |
|
|
|
|
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Get the data URL. |
192
|
|
|
* |
193
|
|
|
* @return string Returns the data URL. |
194
|
|
|
* @deprecated |
195
|
|
|
*/ |
196
|
|
|
public function getDataURL() { |
197
|
|
|
return $this->dataURL; |
|
|
|
|
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Get the id. |
202
|
|
|
* |
203
|
|
|
* @return string Returns the id. |
204
|
|
|
*/ |
205
|
|
|
public function getId() { |
206
|
|
|
return $this->id; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Get the index. |
211
|
|
|
* |
212
|
|
|
* @return integer Returns the index. |
213
|
|
|
*/ |
214
|
|
|
public function getIndex() { |
215
|
|
|
return $this->index; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Get the legend index. |
220
|
|
|
* |
221
|
|
|
* @return integer Returns the legend index. |
222
|
|
|
*/ |
223
|
|
|
public function getLegendIndex() { |
224
|
|
|
return $this->legendIndex; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Get the name. |
229
|
|
|
* |
230
|
|
|
* @return string Returns the name. |
231
|
|
|
*/ |
232
|
|
|
public function getName() { |
233
|
|
|
return $this->name; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Get the stack. |
238
|
|
|
* |
239
|
|
|
* @return string Returns the stack. |
240
|
|
|
*/ |
241
|
|
|
public function getStack() { |
242
|
|
|
return $this->stack; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Get the type. |
247
|
|
|
* |
248
|
|
|
* @return string Returns the type. |
249
|
|
|
*/ |
250
|
|
|
public function getType() { |
251
|
|
|
return $this->type; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* Get the x axis. |
256
|
|
|
* |
257
|
|
|
* @return integer|string Returns the x axis. |
258
|
|
|
*/ |
259
|
|
|
public function getXAxis() { |
260
|
|
|
return $this->xAxis; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Get the y axis. |
265
|
|
|
* |
266
|
|
|
* @return integer|string Returns the y axis. |
267
|
|
|
*/ |
268
|
|
|
public function getYAxis() { |
269
|
|
|
return $this->yAxis; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Get the z index. |
274
|
|
|
* |
275
|
|
|
* @return integer Returns the z index. |
276
|
|
|
*/ |
277
|
|
|
public function getZIndex() { |
278
|
|
|
return $this->zIndex; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Serialize this instance. |
283
|
|
|
* |
284
|
|
|
* @return array Returns an array representing this instance. |
285
|
|
|
*/ |
286
|
|
|
public function jsonSerialize() { |
287
|
|
|
return $this->toArray(); |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* Set the data. |
292
|
|
|
* |
293
|
|
|
* @param array $data The data. |
294
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
295
|
|
|
*/ |
296
|
|
|
public function setData(array $data = null) { |
297
|
|
|
$this->data = $data; |
|
|
|
|
298
|
|
|
return $this; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* Set the data parser. |
303
|
|
|
* |
304
|
|
|
* @param string $dataParser The data parser. |
305
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
306
|
|
|
* @deprecated |
307
|
|
|
*/ |
308
|
|
|
public function setDataParser($dataParser) { |
309
|
|
|
$this->dataParser = $dataParser; |
|
|
|
|
310
|
|
|
return $this; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* Set the data URL. |
315
|
|
|
* |
316
|
|
|
* @param string $dataURL The data URL. |
317
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
318
|
|
|
* @deprecated |
319
|
|
|
*/ |
320
|
|
|
public function setDataURL($dataURL) { |
321
|
|
|
$this->dataURL = $dataURL; |
|
|
|
|
322
|
|
|
return $this; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* Set the id. |
327
|
|
|
* |
328
|
|
|
* @param string $id The id. |
329
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
330
|
|
|
*/ |
331
|
|
|
public function setId($id) { |
332
|
|
|
$this->id = $id; |
333
|
|
|
return $this; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* Set the index. |
338
|
|
|
* |
339
|
|
|
* @param integer $index The index. |
340
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
341
|
|
|
*/ |
342
|
|
|
public function setIndex($index) { |
343
|
|
|
$this->index = $index; |
344
|
|
|
return $this; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* Set the legend index. |
349
|
|
|
* |
350
|
|
|
* @param integer $legendIndex The legend index. |
351
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
352
|
|
|
*/ |
353
|
|
|
public function setLegendIndex($legendIndex) { |
354
|
|
|
$this->legendIndex = $legendIndex; |
355
|
|
|
return $this; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Set the name. |
360
|
|
|
* |
361
|
|
|
* @param string $name The name. |
362
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
363
|
|
|
*/ |
364
|
|
|
public function setName($name) { |
365
|
|
|
$this->name = $name; |
366
|
|
|
return $this; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Set the stack. |
371
|
|
|
* |
372
|
|
|
* @param string $stack The stack. |
373
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
374
|
|
|
*/ |
375
|
|
|
public function setStack($stack) { |
376
|
|
|
$this->stack = $stack; |
377
|
|
|
return $this; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* Set the type. |
382
|
|
|
* |
383
|
|
|
* @param string $type The type. |
384
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
385
|
|
|
*/ |
386
|
|
|
public function setType($type) { |
387
|
|
|
switch ($type) { |
388
|
|
|
case null: |
389
|
|
|
case "area": |
390
|
|
|
case "arearange": |
391
|
|
|
case "areaspline": |
392
|
|
|
case "areasplinerange": |
393
|
|
|
case "boxplot": |
394
|
|
|
case "bubble": |
395
|
|
|
case "column": |
396
|
|
|
case "columnrange": |
397
|
|
|
case "errorbar": |
398
|
|
|
case "funnel": |
399
|
|
|
case "gauge": |
400
|
|
|
case "line": |
401
|
|
|
case "pie": |
402
|
|
|
case "scatter": |
403
|
|
|
case "spline": |
404
|
|
|
case "waterfall": |
405
|
|
|
$this->type = $type; |
406
|
|
|
break; |
407
|
|
|
} |
408
|
|
|
return $this; |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* Set the x axis. |
413
|
|
|
* |
414
|
|
|
* @param integer|string $xAxis The x axis. |
415
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
416
|
|
|
*/ |
417
|
|
|
public function setXAxis($xAxis) { |
418
|
|
|
$this->xAxis = $xAxis; |
419
|
|
|
return $this; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Set the y axis. |
424
|
|
|
* |
425
|
|
|
* @param integer|string $yAxis The y axis. |
426
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
427
|
|
|
*/ |
428
|
|
|
public function setYAxis($yAxis) { |
429
|
|
|
$this->yAxis = $yAxis; |
430
|
|
|
return $this; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* Set the z index. |
435
|
|
|
* |
436
|
|
|
* @param integer $zIndex The z index. |
437
|
|
|
* @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsSeries Returns the highcharts series. |
438
|
|
|
*/ |
439
|
|
|
public function setZIndex($zIndex) { |
440
|
|
|
$this->zIndex = $zIndex; |
441
|
|
|
return $this; |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* Convert into an array representing this instance. |
446
|
|
|
* |
447
|
|
|
* @return array Returns an array representing this instance. |
448
|
|
|
*/ |
449
|
|
|
public function toArray() { |
450
|
|
|
|
451
|
|
|
// Initialize the output. |
452
|
|
|
$output = []; |
453
|
|
|
|
454
|
|
|
// Set the data. |
455
|
|
|
ArrayUtility::set($output, "data", $this->data, [null]); |
456
|
|
|
|
457
|
|
|
// Set the data parser. |
458
|
|
|
ArrayUtility::set($output, "dataParser", $this->dataParser, [null]); |
|
|
|
|
459
|
|
|
|
460
|
|
|
// Set the data URL. |
461
|
|
|
ArrayUtility::set($output, "dataURL", $this->dataURL, [null]); |
|
|
|
|
462
|
|
|
|
463
|
|
|
// Set the id. |
464
|
|
|
ArrayUtility::set($output, "id", $this->id, [null]); |
465
|
|
|
|
466
|
|
|
// Set the index. |
467
|
|
|
ArrayUtility::set($output, "index", $this->index, [null]); |
468
|
|
|
|
469
|
|
|
// Set the legend index. |
470
|
|
|
ArrayUtility::set($output, "legendIndex", $this->legendIndex, [null]); |
471
|
|
|
|
472
|
|
|
// Set the name. |
473
|
|
|
ArrayUtility::set($output, "name", $this->name, [null]); |
474
|
|
|
|
475
|
|
|
// Set the stack. |
476
|
|
|
ArrayUtility::set($output, "stack", $this->stack, [null]); |
477
|
|
|
|
478
|
|
|
// Set the type. |
479
|
|
|
ArrayUtility::set($output, "type", $this->type, [null]); |
480
|
|
|
|
481
|
|
|
// Set the x axis. |
482
|
|
|
ArrayUtility::set($output, "xAxis", $this->xAxis, [null]); |
483
|
|
|
|
484
|
|
|
// Set the y axis. |
485
|
|
|
ArrayUtility::set($output, "yAxis", $this->yAxis, [null]); |
486
|
|
|
|
487
|
|
|
// Set the z index. |
488
|
|
|
ArrayUtility::set($output, "zIndex", $this->zIndex, [null]); |
489
|
|
|
|
490
|
|
|
// Return the output. |
491
|
|
|
return $output; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
} |
495
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..