Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Chart; 4 5 /** 6 * Created by PhpStorm. 7 * User: Wiktor Trzonkowski 8 * Date: 6/17/14 9 * Time: 12:11 PM. 10 */ 11 class Axis extends Properties 12 { 13 /** 14 * Axis Number. 15 * 16 * @var mixed[] 17 */ 18 private $axisNumber = [ 19 'format' => self::FORMAT_CODE_GENERAL, 20 'source_linked' => 1, 21 ]; 22 23 /** 24 * Axis Options. 25 * 26 * @var mixed[] 27 */ 28 private $axisOptions = [ 29 'minimum' => null, 30 'maximum' => null, 31 'major_unit' => null, 32 'minor_unit' => null, 33 'orientation' => self::ORIENTATION_NORMAL, 34 'minor_tick_mark' => self::TICK_MARK_NONE, 35 'major_tick_mark' => self::TICK_MARK_NONE, 36 'axis_labels' => self::AXIS_LABELS_NEXT_TO, 37 'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO, 38 'horizontal_crosses_value' => null, 39 ]; 40 41 /** 42 * Fill Properties. 43 * 44 * @var mixed[] 45 */ 46 private $fillProperties = [ 47 'type' => self::EXCEL_COLOR_TYPE_ARGB, 48 'value' => null, 49 'alpha' => 0, 50 ]; 51 52 /** 53 * Line Properties. 54 * 55 * @var mixed[] 56 */ 57 private $lineProperties = [ 58 'type' => self::EXCEL_COLOR_TYPE_ARGB, 59 'value' => null, 60 'alpha' => 0, 61 ]; 62 63 /** 64 * Line Style Properties. 65 * 66 * @var mixed[] 67 */ 68 private $lineStyleProperties = [ 69 'width' => '9525', 70 'compound' => self::LINE_STYLE_COMPOUND_SIMPLE, 71 'dash' => self::LINE_STYLE_DASH_SOLID, 72 'cap' => self::LINE_STYLE_CAP_FLAT, 73 'join' => self::LINE_STYLE_JOIN_BEVEL, 74 'arrow' => [ 75 'head' => [ 76 'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW, 77 'size' => self::LINE_STYLE_ARROW_SIZE_5, 78 ], 79 'end' => [ 80 'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW, 81 'size' => self::LINE_STYLE_ARROW_SIZE_8, 82 ], 83 ], 84 ]; 85 86 /** 87 * Shadow Properties. 88 * 89 * @var mixed[] 90 */ 91 private $shadowProperties = [ 92 'presets' => self::SHADOW_PRESETS_NOSHADOW, 93 'effect' => null, 94 'color' => [ 95 'type' => self::EXCEL_COLOR_TYPE_STANDARD, 96 'value' => 'black', 97 'alpha' => 40, 98 ], 99 'size' => [ 100 'sx' => null, 101 'sy' => null, 102 'kx' => null, 103 ], 104 'blur' => null, 105 'direction' => null, 106 'distance' => null, 107 'algn' => null, 108 'rotWithShape' => null, 109 ]; 110 111 /** 112 * Glow Properties. 113 * 114 * @var mixed[] 115 */ 116 private $glowProperties = [ 117 'size' => null, 118 'color' => [ 119 'type' => self::EXCEL_COLOR_TYPE_STANDARD, 120 'value' => 'black', 121 'alpha' => 40, 122 ], 123 ]; 124 125 /** 126 * Soft Edge Properties. 127 * 128 * @var mixed[] 129 */ 130 private $softEdges = [ 131 'size' => null, 132 ]; 133 134 /** 135 * Get Series Data Type. 136 * 137 * @param mixed $format_code 138 */ 139 public function setAxisNumberProperties($format_code): void 140 { 141 $this->axisNumber['format'] = (string) $format_code; 142 $this->axisNumber['source_linked'] = 0; 143 } 144 145 /** 146 * Get Axis Number Format Data Type. 147 * 148 * @return string 149 */ 150 public function getAxisNumberFormat() 151 { 152 return $this->axisNumber['format']; 153 } 154 155 /** 156 * Get Axis Number Source Linked. 157 * 158 * @return string 159 */ 160 public function getAxisNumberSourceLinked() 161 { 162 return (string) $this->axisNumber['source_linked']; 163 } 164 165 /** 166 * Set Axis Options Properties. 167 * 168 * @param string $axisLabels 169 * @param string $horizontalCrossesValue 170 * @param string $horizontalCrosses 171 * @param string $axisOrientation 172 * @param string $majorTmt 173 * @param string $minorTmt 174 * @param string $minimum 175 * @param string $maximum 176 * @param string $majorUnit 177 * @param string $minorUnit 178 */ 179 public function setAxisOptionsProperties($axisLabels, $horizontalCrossesValue = null, $horizontalCrosses = null, $axisOrientation = null, $majorTmt = null, $minorTmt = null, $minimum = null, $maximum = null, $majorUnit = null, $minorUnit = null): void 180 { 181 $this->axisOptions['axis_labels'] = (string) $axisLabels; 182 ($horizontalCrossesValue !== null) ? $this->axisOptions['horizontal_crosses_value'] = (string) $horizontalCrossesValue : null; 183 ($horizontalCrosses !== null) ? $this->axisOptions['horizontal_crosses'] = (string) $horizontalCrosses : null; 184 ($axisOrientation !== null) ? $this->axisOptions['orientation'] = (string) $axisOrientation : null; 185 ($majorTmt !== null) ? $this->axisOptions['major_tick_mark'] = (string) $majorTmt : null; 186 ($minorTmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minorTmt : null; 187 ($minorTmt !== null) ? $this->axisOptions['minor_tick_mark'] = (string) $minorTmt : null; 188 ($minimum !== null) ? $this->axisOptions['minimum'] = (string) $minimum : null; 189 ($maximum !== null) ? $this->axisOptions['maximum'] = (string) $maximum : null; 190 ($majorUnit !== null) ? $this->axisOptions['major_unit'] = (string) $majorUnit : null; 191 ($minorUnit !== null) ? $this->axisOptions['minor_unit'] = (string) $minorUnit : null; 192 } 193 194 /** 195 * Get Axis Options Property. 196 * 197 * @param string $property 198 * 199 * @return string 200 */ 201 public function getAxisOptionsProperty($property) 202 { 203 return $this->axisOptions[$property]; 204 } 205 206 /** 207 * Set Axis Orientation Property. 208 * 209 * @param string $orientation 210 */ 211 public function setAxisOrientation($orientation): void 212 { 213 $this->axisOptions['orientation'] = (string) $orientation; 214 } 215 216 /** 217 * Set Fill Property. 218 * 219 * @param string $color 220 * @param int $alpha 221 * @param string $AlphaType 222 */ 223 public function setFillParameters($color, $alpha = 0, $AlphaType = self::EXCEL_COLOR_TYPE_ARGB): void 224 { 225 $this->fillProperties = $this->setColorProperties($color, $alpha, $AlphaType); 226 } 227 228 /** 229 * Set Line Property. 230 * 231 * @param string $color 232 * @param int $alpha 233 * @param string $alphaType 234 */ 235 public function setLineParameters($color, $alpha = 0, $alphaType = self::EXCEL_COLOR_TYPE_ARGB): void 236 { 237 $this->lineProperties = $this->setColorProperties($color, $alpha, $alphaType); 238 } 239 240 /** 241 * Get Fill Property. 242 * 243 * @param string $property 244 * 245 * @return string 246 */ 247 public function getFillProperty($property) 248 { 249 return $this->fillProperties[$property]; 250 } 251 252 /** 253 * Get Line Property. 254 * 255 * @param string $property 256 * 257 * @return string 258 */ 259 public function getLineProperty($property) 260 { 261 return $this->lineProperties[$property]; 262 } 263 264 /** 265 * Set Line Style Properties. 266 * 267 * @param float $lineWidth 268 * @param string $compoundType 269 * @param string $dashType 270 * @param string $capType 271 * @param string $joinType 272 * @param string $headArrowType 273 * @param string $headArrowSize 274 * @param string $endArrowType 275 * @param string $endArrowSize 276 */ 277 public function setLineStyleProperties($lineWidth = null, $compoundType = null, $dashType = null, $capType = null, $joinType = null, $headArrowType = null, $headArrowSize = null, $endArrowType = null, $endArrowSize = null): void 278 { 279 ($lineWidth !== null) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $lineWidth) : null; 280 ($compoundType !== null) ? $this->lineStyleProperties['compound'] = (string) $compoundType : null; 281 ($dashType !== null) ? $this->lineStyleProperties['dash'] = (string) $dashType : null; 282 ($capType !== null) ? $this->lineStyleProperties['cap'] = (string) $capType : null; 283 ($joinType !== null) ? $this->lineStyleProperties['join'] = (string) $joinType : null; 284 ($headArrowType !== null) ? $this->lineStyleProperties['arrow']['head']['type'] = (string) $headArrowType : null; 285 ($headArrowSize !== null) ? $this->lineStyleProperties['arrow']['head']['size'] = (string) $headArrowSize : null; 286 ($endArrowType !== null) ? $this->lineStyleProperties['arrow']['end']['type'] = (string) $endArrowType : null; 287 ($endArrowSize !== null) ? $this->lineStyleProperties['arrow']['end']['size'] = (string) $endArrowSize : null; 288 } 289 290 /** 291 * Get Line Style Property. 292 * 293 * @param array|string $elements 294 * 295 * @return string 296 */ 297 public function getLineStyleProperty($elements) 298 { 299 return $this->getArrayElementsValue($this->lineStyleProperties, $elements); 300 } 301 302 /** 303 * Get Line Style Arrow Excel Width. 304 * 305 * @param string $arrow 306 * 307 * @return string 308 */ 309 public function getLineStyleArrowWidth($arrow) 310 { 311 return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrow]['size'], 'w'); 312 } 313 314 /** 315 * Get Line Style Arrow Excel Length. 316 * 317 * @param string $arrow 318 * 319 * @return string 320 */ 321 public function getLineStyleArrowLength($arrow) 322 { 323 return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrow]['size'], 'len'); 324 } 325 326 /** 327 * Set Shadow Properties. 328 * 329 * @param int $shadowPresets 330 * @param string $colorValue 331 * @param string $colorType 332 * @param string $colorAlpha 333 * @param float $blur 334 * @param int $angle 335 * @param float $distance 336 */ 337 public function setShadowProperties($shadowPresets, $colorValue = null, $colorType = null, $colorAlpha = null, $blur = null, $angle = null, $distance = null): void 338 { 339 $this->setShadowPresetsProperties((int) $shadowPresets) 340 ->setShadowColor( 341 $colorValue ?? $this->shadowProperties['color']['value'], 342 $colorAlpha ?? (int) $this->shadowProperties['color']['alpha'], 343 $colorType ?? $this->shadowProperties['color']['type'] 344 ) 345 ->setShadowBlur($blur) 346 ->setShadowAngle($angle) 347 ->setShadowDistance($distance); 348 } 349 350 /** 351 * Set Shadow Color. 352 * 353 * @param int $presets 354 * 355 * @return $this 356 */ 357 private function setShadowPresetsProperties($presets) 358 { 359 $this->shadowProperties['presets'] = $presets; 360 $this->setShadowPropertiesMapValues($this->getShadowPresetsMap($presets)); 361 362 return $this; 363 } 364 365 /** 366 * Set Shadow Properties from Mapped Values. 367 * 368 * @param mixed $reference 369 * 370 * @return $this 371 */ 372 private function setShadowPropertiesMapValues(array $propertiesMap, &$reference = null) 373 { 374 $base_reference = $reference; 375 foreach ($propertiesMap as $property_key => $property_val) { 376 if (is_array($property_val)) { 377 if ($reference === null) { 378 $reference = &$this->shadowProperties[$property_key]; 379 } else { 380 $reference = &$reference[$property_key]; 381 } 382 $this->setShadowPropertiesMapValues($property_val, $reference); 383 } else { 384 if ($base_reference === null) { 385 $this->shadowProperties[$property_key] = $property_val; 386 } else { 387 $reference[$property_key] = $property_val; 388 } 389 } 390 } 391 392 return $this; 393 } 394 395 /** 396 * Set Shadow Color. 397 * 398 * @param string $color 399 * @param int $alpha 400 * @param string $alphaType 401 * 402 * @return $this 403 */ 404 private function setShadowColor($color, $alpha, $alphaType) 405 { 406 $this->shadowProperties['color'] = $this->setColorProperties($color, $alpha, $alphaType); 407 408 return $this; 409 } 410 411 /** 412 * Set Shadow Blur. 413 * 414 * @param float $blur 415 * 416 * @return $this 417 */ 418 private function setShadowBlur($blur) 419 { 420 if ($blur !== null) { 421 $this->shadowProperties['blur'] = (string) $this->getExcelPointsWidth($blur); 422 } 423 424 return $this; 425 } 426 427 /** 428 * Set Shadow Angle. 429 * 430 * @param int $angle 431 * 432 * @return $this 433 */ 434 private function setShadowAngle($angle) 435 { 436 if ($angle !== null) { 437 $this->shadowProperties['direction'] = (string) $this->getExcelPointsAngle($angle); 438 } 439 440 return $this; 441 } 442 443 /** 444 * Set Shadow Distance. 445 * 446 * @param float $distance 447 * 448 * @return $this 449 */ 450 private function setShadowDistance($distance) 451 { 452 if ($distance !== null) { 453 $this->shadowProperties['distance'] = (string) $this->getExcelPointsWidth($distance); 454 } 455 456 return $this; 457 } 458 459 /** 460 * Get Shadow Property. 461 * 462 * @param string|string[] $elements 463 * 464 * @return null|array|int|string 465 */ 466 public function getShadowProperty($elements) 467 { 468 return $this->getArrayElementsValue($this->shadowProperties, $elements); 469 } 470 471 /** 472 * Set Glow Properties. 473 * 474 * @param float $size 475 * @param string $colorValue 476 * @param int $colorAlpha 477 * @param string $colorType 478 */ 479 public function setGlowProperties($size, $colorValue = null, $colorAlpha = null, $colorType = null): void 480 { 481 $this->setGlowSize($size) 482 ->setGlowColor( 483 $colorValue ?? $this->glowProperties['color']['value'], 484 $colorAlpha ?? (int) $this->glowProperties['color']['alpha'], 485 $colorType ?? $this->glowProperties['color']['type'] 486 ); 487 } 488 489 /** 490 * Get Glow Property. 491 * 492 * @param array|string $property 493 * 494 * @return string 495 */ 496 public function getGlowProperty($property) 497 { 498 return $this->getArrayElementsValue($this->glowProperties, $property); 499 } 500 501 /** 502 * Set Glow Color. 503 * 504 * @param float $size 505 * 506 * @return $this 507 */ 508 private function setGlowSize($size) 509 { 510 if ($size !== null) { 511 $this->glowProperties['size'] = $this->getExcelPointsWidth($size); 512 } 513 514 return $this; 515 } 516 517 /** 518 * Set Glow Color. 519 * 520 * @param string $color 521 * @param int $alpha 522 * @param string $colorType 523 * 524 * @return $this 525 */ 526 private function setGlowColor($color, $alpha, $colorType) 527 { 528 $this->glowProperties['color'] = $this->setColorProperties($color, $alpha, $colorType); 529 530 return $this; 531 } 532 533 /** 534 * Set Soft Edges Size. 535 * 536 * @param float $size 537 */ 538 public function setSoftEdges($size): void 539 { 540 if ($size !== null) { 541 $softEdges['size'] = (string) $this->getExcelPointsWidth($size); 542 } 543 } 544 545 /** 546 * Get Soft Edges Size. 547 * 548 * @return string 549 */ 550 public function getSoftEdgesSize() 551 { 552 return $this->softEdges['size']; 553 } 554 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body