Skip to content

Commit

Permalink
Workaround for line chart fill color
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagomalheiro committed May 31, 2019
1 parent d6018a2 commit f90caf0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/PhpSpreadsheet/Writer/Xlsx/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f90caf0

Please sign in to comment.