From f90caf00185e9f1d9d5d43dcb1aebcefd6fddcdd Mon Sep 17 00:00:00 2001 From: Tiago Malheiro Date: Fri, 31 May 2019 18:47:57 +0100 Subject: [PATCH] Workaround for line chart fill color See https://github.com/PHPOffice/PhpSpreadsheet/issues/589 --- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 625fd16de2..590690f87e 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -260,7 +260,7 @@ private function writePlotArea(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\W if ($chartType === DataSeries::TYPE_LINECHART) { // Line only, Line3D can't be smoothed $objWriter->startElement('c:smooth'); - $objWriter->writeAttribute('val', (int) $plotGroup->getSmoothLine()); + $objWriter->writeAttribute('val', (int)$plotGroup->getSmoothLine()); $objWriter->endElement(); } elseif (($chartType === DataSeries::TYPE_BARCHART) || ($chartType === DataSeries::TYPE_BARCHART_3D)) { $objWriter->startElement('c:gapWidth'); @@ -1108,7 +1108,7 @@ private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMulti $objWriter->startElement('c:ser'); $plotLabel = $plotGroup->getPlotLabelByIndex($plotSeriesIdx); - if ($plotLabel) { + if ($plotLabel && $groupType !== DataSeries::TYPE_LINECHART) { $fillColor = $plotLabel->getFillColor(); if ($fillColor !== null && !is_array($fillColor)) { $objWriter->startElement('c:spPr'); @@ -1166,6 +1166,13 @@ private function writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMulti if ($groupType == DataSeries::TYPE_STOCKCHART) { $objWriter->startElement('a:noFill'); $objWriter->endElement(); + } elseif ($plotLabel && $plotLabel->getFillColor() !== null) { + $fillColor = $plotLabel->getFillColor(); + $objWriter->startElement('a:solidFill'); + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', $fillColor); + $objWriter->endElement(); + $objWriter->endElement(); } $objWriter->endElement(); $objWriter->endElement();