1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of PHPPresentation - A pure PHP library for reading and writing |
4
|
|
|
* presentations documents. |
5
|
|
|
* |
6
|
|
|
* PHPPresentation is free software distributed under the terms of the GNU Lesser |
7
|
|
|
* General Public License version 3 as published by the Free Software Foundation. |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please read the LICENSE |
10
|
|
|
* file that was distributed with this source code. For the full list of |
11
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
12
|
|
|
* |
13
|
|
|
* @link https://github.com/PHPOffice/PHPPresentation |
14
|
|
|
* @copyright 2009-2015 PHPPresentation contributors |
15
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace PhpOffice\PhpPresentation\Shape\Chart; |
19
|
|
|
|
20
|
|
|
use PhpOffice\PhpPresentation\ComparableInterface; |
21
|
|
|
use PhpOffice\PhpPresentation\Style\Fill; |
22
|
|
|
use PhpOffice\PhpPresentation\Style\Font; |
23
|
|
|
use PhpOffice\PhpPresentation\Style\Outline; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* \PhpOffice\PhpPresentation\Shape\Chart\Series |
27
|
|
|
*/ |
28
|
|
|
class Series implements ComparableInterface |
29
|
|
|
{ |
30
|
|
|
/* Label positions */ |
31
|
|
|
const LABEL_BESTFIT = 'bestFit'; |
32
|
|
|
const LABEL_BOTTOM = 'b'; |
33
|
|
|
const LABEL_CENTER = 'ctr'; |
34
|
|
|
const LABEL_INSIDEBASE = 'inBase'; |
35
|
|
|
const LABEL_INSIDEEND = 'inEnd'; |
36
|
|
|
const LABEL_LEFT = 'i'; |
37
|
|
|
const LABEL_OUTSIDEEND = 'outEnd'; |
38
|
|
|
const LABEL_RIGHT = 'r'; |
39
|
|
|
const LABEL_TOP = 't'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* DataPointFills (key/value) |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
protected $dataPointFills = array(); |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Data Label Number Format |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
protected $DlblNumFormat = ''; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Separator |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
protected $separator = null; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Fill |
61
|
|
|
* @var \PhpOffice\PhpPresentation\Style\Fill |
62
|
|
|
*/ |
63
|
|
|
protected $fill; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Font |
67
|
|
|
* @var \PhpOffice\PhpPresentation\Style\Font |
68
|
|
|
*/ |
69
|
|
|
protected $font; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Label position |
73
|
|
|
* @var string |
74
|
|
|
*/ |
75
|
|
|
protected $labelPosition = 'ctr'; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @var Marker |
79
|
|
|
*/ |
80
|
|
|
protected $marker; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @var Outline |
84
|
|
|
*/ |
85
|
|
|
protected $outline; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Show Category Name |
89
|
|
|
* @var boolean |
90
|
|
|
*/ |
91
|
|
|
private $showCategoryName = false; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Show Leader Lines |
95
|
|
|
* @var boolean |
96
|
|
|
*/ |
97
|
|
|
private $showLeaderLines = true; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Show Legend Key |
101
|
|
|
* @var boolean |
102
|
|
|
*/ |
103
|
|
|
private $showLegendKey = false; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* ShowPercentage |
107
|
|
|
* @var boolean |
108
|
|
|
*/ |
109
|
|
|
private $showPercentage = false; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* ShowSeriesName |
113
|
|
|
* @var boolean |
114
|
|
|
*/ |
115
|
|
|
private $showSeriesName = false; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* ShowValue |
119
|
|
|
* @var boolean |
120
|
|
|
*/ |
121
|
|
|
private $showValue = true; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Title |
125
|
|
|
* @var string |
126
|
|
|
*/ |
127
|
|
|
private $title = 'Series Title'; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Values (key/value) |
131
|
|
|
* @var array |
132
|
|
|
*/ |
133
|
|
|
private $values = array(); |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Hash index |
137
|
|
|
* @var string |
138
|
|
|
*/ |
139
|
|
|
private $hashIndex; |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Series instance |
143
|
|
|
* |
144
|
|
|
* @param string $title Title |
145
|
|
|
* @param array $values Values |
146
|
|
|
*/ |
147
|
98 |
|
public function __construct($title = 'Series Title', $values = array()) |
148
|
|
|
{ |
149
|
98 |
|
$this->fill = new Fill(); |
150
|
98 |
|
$this->font = new Font(); |
151
|
98 |
|
$this->font->setName('Calibri'); |
152
|
98 |
|
$this->font->setSize(9); |
153
|
98 |
|
$this->title = $title; |
154
|
98 |
|
$this->values = $values; |
155
|
98 |
|
$this->marker = new Marker(); |
156
|
98 |
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Get Title |
160
|
|
|
* |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
54 |
|
public function getTitle() |
164
|
|
|
{ |
165
|
54 |
|
return $this->title; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Set Title |
170
|
|
|
* |
171
|
|
|
* @param string $value |
172
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
173
|
|
|
*/ |
174
|
1 |
|
public function setTitle($value = 'Series Title') |
175
|
|
|
{ |
176
|
1 |
|
$this->title = $value; |
177
|
|
|
|
178
|
1 |
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Get Data Label NumFormat |
183
|
|
|
* |
184
|
|
|
* @return string |
185
|
|
|
*/ |
186
|
1 |
|
public function getDlblNumFormat() |
187
|
|
|
{ |
188
|
1 |
|
return $this->DlblNumFormat; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Has Data Label NumFormat |
193
|
|
|
* |
194
|
|
|
* @return string |
195
|
|
|
*/ |
196
|
6 |
|
public function hasDlblNumFormat() |
197
|
|
|
{ |
198
|
6 |
|
return !empty($this->DlblNumFormat); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Set Data Label NumFormat |
203
|
|
|
* |
204
|
|
|
* @param string $value |
205
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
206
|
|
|
*/ |
207
|
1 |
|
public function setDlblNumFormat($value = '') |
208
|
|
|
{ |
209
|
1 |
|
$this->DlblNumFormat = $value; |
210
|
1 |
|
return $this; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get Fill |
215
|
|
|
* |
216
|
|
|
* @return \PhpOffice\PhpPresentation\Style\Fill |
217
|
|
|
*/ |
218
|
49 |
|
public function getFill() |
219
|
|
|
{ |
220
|
49 |
|
return $this->fill; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Set Fill |
225
|
|
|
* |
226
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Fill $fill |
227
|
|
|
* @return Series |
228
|
|
|
*/ |
229
|
1 |
|
public function setFill(Fill $fill = null) |
230
|
|
|
{ |
231
|
1 |
|
$this->fill = $fill; |
232
|
1 |
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Get DataPointFill |
237
|
|
|
* |
238
|
|
|
* @param int $dataPointIndex Data point index. |
239
|
|
|
* @return \PhpOffice\PhpPresentation\Style\Fill |
240
|
|
|
*/ |
241
|
13 |
|
public function getDataPointFill($dataPointIndex) |
242
|
|
|
{ |
243
|
13 |
|
if (!isset($this->dataPointFills[$dataPointIndex])) { |
244
|
13 |
|
$this->dataPointFills[$dataPointIndex] = new Fill(); |
245
|
|
|
} |
246
|
|
|
|
247
|
13 |
|
return $this->dataPointFills[$dataPointIndex]; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Get DataPointFills |
252
|
|
|
* |
253
|
|
|
* @return Fill[] |
254
|
|
|
*/ |
255
|
36 |
|
public function getDataPointFills() |
256
|
|
|
{ |
257
|
36 |
|
return $this->dataPointFills; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Get Values |
262
|
|
|
* |
263
|
|
|
* @return array |
264
|
|
|
*/ |
265
|
55 |
|
public function getValues() |
266
|
|
|
{ |
267
|
55 |
|
return $this->values; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Set Values |
272
|
|
|
* |
273
|
|
|
* @param array $value |
274
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
275
|
|
|
*/ |
276
|
1 |
|
public function setValues($value = array()) |
277
|
|
|
{ |
278
|
1 |
|
$this->values = $value; |
279
|
|
|
|
280
|
1 |
|
return $this; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Add Value |
285
|
|
|
* |
286
|
|
|
* @param mixed $key |
287
|
|
|
* @param mixed $value |
288
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
289
|
|
|
*/ |
290
|
1 |
|
public function addValue($key, $value) |
291
|
|
|
{ |
292
|
1 |
|
$this->values[$key] = $value; |
293
|
|
|
|
294
|
1 |
|
return $this; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* Get ShowSeriesName |
299
|
|
|
* |
300
|
|
|
* @return boolean |
301
|
|
|
*/ |
302
|
31 |
|
public function hasShowSeriesName() |
303
|
|
|
{ |
304
|
31 |
|
return $this->showSeriesName; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* Set ShowSeriesName |
309
|
|
|
* |
310
|
|
|
* @param boolean $value |
311
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
312
|
|
|
*/ |
313
|
11 |
|
public function setShowSeriesName($value) |
314
|
|
|
{ |
315
|
11 |
|
$this->showSeriesName = $value; |
316
|
|
|
|
317
|
11 |
|
return $this; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Get ShowCategoryName |
322
|
|
|
* |
323
|
|
|
* @return boolean |
324
|
|
|
*/ |
325
|
53 |
|
public function hasShowCategoryName() |
326
|
|
|
{ |
327
|
53 |
|
return $this->showCategoryName; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* Set ShowCategoryName |
332
|
|
|
* |
333
|
|
|
* @param boolean $value |
334
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
335
|
|
|
*/ |
336
|
2 |
|
public function setShowCategoryName($value) |
337
|
|
|
{ |
338
|
2 |
|
$this->showCategoryName = $value; |
339
|
|
|
|
340
|
2 |
|
return $this; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* Get ShowValue |
345
|
|
|
* |
346
|
|
|
* @return boolean |
347
|
|
|
*/ |
348
|
10 |
|
public function hasShowLegendKey() |
349
|
|
|
{ |
350
|
10 |
|
return $this->showLegendKey; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Set ShowValue |
355
|
|
|
* |
356
|
|
|
* @param boolean $value |
357
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
358
|
|
|
*/ |
359
|
3 |
|
public function setShowLegendKey($value) |
360
|
|
|
{ |
361
|
3 |
|
$this->showLegendKey = (bool)$value; |
362
|
|
|
|
363
|
3 |
|
return $this; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
/** |
367
|
|
|
* Get ShowValue |
368
|
|
|
* |
369
|
|
|
* @return boolean |
370
|
|
|
*/ |
371
|
53 |
|
public function hasShowValue() |
372
|
|
|
{ |
373
|
53 |
|
return $this->showValue; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* Set ShowValue |
378
|
|
|
* |
379
|
|
|
* @param boolean $value |
380
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
381
|
|
|
*/ |
382
|
2 |
|
public function setShowValue($value) |
383
|
|
|
{ |
384
|
2 |
|
$this->showValue = $value; |
385
|
|
|
|
386
|
2 |
|
return $this; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Get ShowPercentage |
391
|
|
|
* |
392
|
|
|
* @return boolean |
393
|
|
|
*/ |
394
|
54 |
|
public function hasShowPercentage() |
395
|
|
|
{ |
396
|
54 |
|
return $this->showPercentage; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* Set ShowPercentage |
401
|
|
|
* |
402
|
|
|
* @param boolean $value |
403
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
404
|
|
|
*/ |
405
|
2 |
|
public function setShowPercentage($value) |
406
|
|
|
{ |
407
|
2 |
|
$this->showPercentage = $value; |
408
|
|
|
|
409
|
2 |
|
return $this; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* Get ShowLeaderLines |
414
|
|
|
* |
415
|
|
|
* @return boolean |
416
|
|
|
*/ |
417
|
4 |
|
public function hasShowSeparator() |
418
|
|
|
{ |
419
|
4 |
|
return !is_null($this->separator); |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Set Separator |
424
|
|
|
* @param string $pValue |
425
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
426
|
|
|
*/ |
427
|
4 |
|
public function setSeparator($pValue) |
428
|
|
|
{ |
429
|
4 |
|
$this->separator = $pValue; |
430
|
4 |
|
return $this; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* Get Separator |
435
|
|
|
* @return string |
436
|
|
|
*/ |
437
|
30 |
|
public function getSeparator() |
438
|
|
|
{ |
439
|
30 |
|
return $this->separator; |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* Get ShowLeaderLines |
444
|
|
|
* |
445
|
|
|
* @return boolean |
446
|
|
|
*/ |
447
|
30 |
|
public function hasShowLeaderLines() |
448
|
|
|
{ |
449
|
30 |
|
return $this->showLeaderLines; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Set ShowLeaderLines |
454
|
|
|
* |
455
|
|
|
* @param boolean $value |
456
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
457
|
|
|
*/ |
458
|
1 |
|
public function setShowLeaderLines($value) |
459
|
|
|
{ |
460
|
1 |
|
$this->showLeaderLines = $value; |
461
|
|
|
|
462
|
1 |
|
return $this; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
/** |
466
|
|
|
* Get font |
467
|
|
|
* |
468
|
|
|
* @return \PhpOffice\PhpPresentation\Style\Font |
469
|
|
|
*/ |
470
|
54 |
|
public function getFont() |
471
|
|
|
{ |
472
|
54 |
|
return $this->font; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* Set font |
477
|
|
|
* |
478
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Font $pFont Font |
479
|
|
|
* @throws \Exception |
480
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
481
|
|
|
*/ |
482
|
1 |
|
public function setFont(Font $pFont = null) |
483
|
|
|
{ |
484
|
1 |
|
$this->font = $pFont; |
485
|
|
|
|
486
|
1 |
|
return $this; |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Get label position |
491
|
|
|
* |
492
|
|
|
* @return string |
493
|
|
|
*/ |
494
|
9 |
|
public function getLabelPosition() |
495
|
|
|
{ |
496
|
9 |
|
return $this->labelPosition; |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* Set label position |
501
|
|
|
* |
502
|
|
|
* @param string $value |
503
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
504
|
|
|
*/ |
505
|
1 |
|
public function setLabelPosition($value) |
506
|
|
|
{ |
507
|
1 |
|
$this->labelPosition = $value; |
508
|
|
|
|
509
|
1 |
|
return $this; |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* @return Marker |
514
|
|
|
*/ |
515
|
27 |
|
public function getMarker() |
516
|
|
|
{ |
517
|
27 |
|
return $this->marker; |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
/** |
521
|
|
|
* @param Marker $marker |
522
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
523
|
|
|
*/ |
524
|
1 |
|
public function setMarker(Marker $marker) |
525
|
|
|
{ |
526
|
1 |
|
$this->marker = $marker; |
527
|
1 |
|
return $this; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* @return Outline |
532
|
|
|
*/ |
533
|
28 |
|
public function getOutline() |
534
|
|
|
{ |
535
|
28 |
|
return $this->outline; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* @param Outline $outline |
540
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
541
|
|
|
*/ |
542
|
6 |
|
public function setOutline(Outline $outline) |
543
|
|
|
{ |
544
|
6 |
|
$this->outline = $outline; |
545
|
6 |
|
return $this; |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Get hash code |
550
|
|
|
* |
551
|
|
|
* @return string Hash code |
552
|
|
|
*/ |
553
|
61 |
|
public function getHashCode() |
554
|
|
|
{ |
555
|
61 |
|
return md5((is_null($this->fill) ? 'null' : $this->fill->getHashCode()) . (is_null($this->font) ? 'null' : $this->font->getHashCode()) . var_export($this->values, true) . var_export($this, true) . __CLASS__); |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Get hash index |
560
|
|
|
* |
561
|
|
|
* Note that this index may vary during script execution! Only reliable moment is |
562
|
|
|
* while doing a write of a workbook and when changes are not allowed. |
563
|
|
|
* |
564
|
|
|
* @return string Hash index |
565
|
|
|
*/ |
566
|
2 |
|
public function getHashIndex() |
567
|
|
|
{ |
568
|
2 |
|
return $this->hashIndex; |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
/** |
572
|
|
|
* Set hash index |
573
|
|
|
* |
574
|
|
|
* Note that this index may vary during script execution! Only reliable moment is |
575
|
|
|
* while doing a write of a workbook and when changes are not allowed. |
576
|
|
|
* |
577
|
|
|
* @param string $value Hash index |
578
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart\Series |
579
|
|
|
*/ |
580
|
1 |
|
public function setHashIndex($value) |
581
|
|
|
{ |
582
|
1 |
|
$this->hashIndex = $value; |
583
|
1 |
|
return $this; |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* @link http://php.net/manual/en/language.oop5.cloning.php |
589
|
|
|
*/ |
590
|
2 |
|
public function __clone() |
591
|
|
|
{ |
592
|
2 |
|
$this->font = clone $this->font; |
593
|
2 |
|
$this->marker = clone $this->marker; |
594
|
2 |
|
if (is_object($this->outline)) { |
595
|
1 |
|
$this->outline = clone $this->outline; |
596
|
|
|
} |
597
|
2 |
|
} |
598
|
|
|
} |
599
|
|
|
|