From bbd592516b469b047b5f2d8f58e3ce78d920edb9 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 18 Jan 2024 17:42:14 +0300 Subject: [PATCH] BA-5434 extension control of marker and line styles --- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 43 +++++++++++++++++++ src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 17 ++++++++ 2 files changed, 60 insertions(+) diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index ec8b5bb18e..8a7d6c0d8f 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -90,6 +90,12 @@ class DataSeriesValues /** @var bool */ private $showSeparator = false; + /** @var array|null */ + private $markers = null; + + /** @var array|null */ + private $lineType = null; + /** * Create a new DataSeriesValues object. * @@ -433,6 +439,43 @@ public function setShowSeparator(bool $showSeparator): self return $this; } + /** + * @return array|null + */ + public function getMarkers(): ?array + { + return $this->markers; + } + + /** + * @param array arrayPointMarker + * @return self + */ + public function setMarkers(array $markers): self + { + $this->markers = $markers; + + return $this; + } + + /** + * @return array|null + */ + public function getLineType(): ?array + { + return $this->lineType; + } + + /** + * @param array|null $lineType + * @return self + */ + public function setLineType(?array $lineType): self + { + $this->lineType = $lineType; + return $this; + } + /** * Set Series Data Values. * diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 0aa1f987c8..4fb0a3fe7d 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -1283,12 +1283,29 @@ private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMulti if ($fillColor !== null && !is_array($fillColor)) { $this->writeSolidFill($objWriter, $fillColor); } + + if ( + $plotSeriesValues->getLineType() + && $plotSeriesValues->getLineType()[$plotSeriesIdx] + ) { + $objWriter->startElement('a:prstDash'); + $objWriter->writeAttribute('val', $plotSeriesValues->getLineType()[$plotSeriesIdx]); + $objWriter->endElement(); + } + $objWriter->endElement(); $objWriter->endElement(); } if ($plotSeriesValues) { $plotSeriesMarker = $plotSeriesValues->getPointMarker(); + if ( + $plotSeriesValues->getMarkers() + && $plotSeriesValues->getMarkers()[$plotSeriesIdx] + ) { + $plotSeriesMarker = $plotSeriesValues->getMarkers()[$plotSeriesIdx]; + } + $markerSize = $plotSeriesValues->getMarkerSize(); if ($plotSeriesMarker) { $objWriter->startElement('c:marker');