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