From fdd1b208308cf2b9bdc76a4df3606f2df575f81b Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 24 Feb 2012 13:13:38 +0000 Subject: [PATCH] Tweak to varyColors element git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@86902 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Writer/Excel2007/Chart.php | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Classes/PHPExcel/Writer/Excel2007/Chart.php b/Classes/PHPExcel/Writer/Excel2007/Chart.php index 4d4dc820..95c6fceb 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Chart.php +++ b/Classes/PHPExcel/Writer/Excel2007/Chart.php @@ -220,8 +220,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $this->_writeDataLbls($objWriter); - if (($groupType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) || - ($groupType === PHPExcel_Chart_DataSeries::TYPE_LINECHART_3D)) { + if ($groupType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) { + // Line only, Line3D can't be smoothed $objWriter->startElement('c:smooth'); $objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine() ); @@ -567,13 +567,22 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa $objWriter->endElement(); } - // TODO Set to 1 if any plotseries values don't have style colours defined, otherwise set to 0 - $objWriter->startElement('c:varyColors'); - $objWriter->writeAttribute('val', 1); - $objWriter->endElement(); - + // Get these details before the loop, because we can use the count to check for varyColors $plotSeriesOrder = $plotGroup->getPlotOrder(); $plotSeriesCount = count($plotSeriesOrder); + + if (($groupType !== PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) && + ($groupType !== PHPExcel_Chart_DataSeries::TYPE_RADARCHART) && + ($groupType !== PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) { + + if (($groupType !== PHPExcel_Chart_DataSeries::TYPE_LINECHART) || + ($plotSeriesCount > 1)) { + $objWriter->startElement('c:varyColors'); + $objWriter->writeAttribute('val', 1); + $objWriter->endElement(); + } + } + foreach($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) { $objWriter->startElement('c:ser');