From 9d8864d716785436601637be93fe96da477f8790 Mon Sep 17 00:00:00 2001 From: tiria Date: Tue, 31 May 2016 12:43:20 +0200 Subject: [PATCH 1/3] Add displayBlanksAs possible values Add displayBlanksAs possible values and redefine default value to 'gap' (already 'gap' returned in excel2007 writer) --- Classes/PHPExcel/Chart.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Classes/PHPExcel/Chart.php b/Classes/PHPExcel/Chart.php index d7799935b..5f904c0e1 100644 --- a/Classes/PHPExcel/Chart.php +++ b/Classes/PHPExcel/Chart.php @@ -27,6 +27,21 @@ */ class PHPExcel_Chart { + const DISPLAY_BLANKS_AS_GAP = 'gap'; + const DISPLAY_BLANKS_AS_ZERO = 'zero'; + const DISPLAY_BLANKS_AS_SPAN = 'span'; + + /** + * DisplayBlanksAs possible values + * + * @var array + */ + private static $displayBlanksAsValues = array( + self::DISPLAY_BLANKS_AS_GAP, + self::DISPLAY_BLANKS_AS_ZERO, + self::DISPLAY_BLANKS_AS_SPAN, + ); + /** * Chart Name * @@ -88,7 +103,7 @@ class PHPExcel_Chart * * @var string */ - private $displayBlanksAs = '0'; + private $displayBlanksAs = self::DISPLAY_BLANKS_AS_GAP; /** * Chart Asix Y as @@ -169,7 +184,7 @@ class PHPExcel_Chart /** * Create a new PHPExcel_Chart */ - public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null) + public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = self::DISPLAY_BLANKS_AS_GAP, PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null) { $this->name = $name; $this->title = $title; @@ -178,7 +193,7 @@ public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_ $this->yAxisLabel = $yAxisLabel; $this->plotArea = $plotArea; $this->plotVisibleOnly = $plotVisibleOnly; - $this->displayBlanksAs = $displayBlanksAs; + $this->displayBlanksAs = (in_array($displayBlanksAs,$this->displayBlanksAsValues)) ? $displayBlanksAs : self::DISPLAY_BLANKS_AS_GAP; $this->xAxis = $xAxis; $this->yAxis = $yAxis; $this->majorGridlines = $majorGridlines; @@ -360,9 +375,9 @@ public function getDisplayBlanksAs() * @param string $displayBlanksAs * @return PHPExcel_Chart */ - public function setDisplayBlanksAs($displayBlanksAs = '0') + public function setDisplayBlanksAs($displayBlanksAs = self::DISPLAY_BLANKS_AS_GAP) { - $this->displayBlanksAs = $displayBlanksAs; + $this->displayBlanksAs = (in_array($displayBlanksAs,$this->displayBlanksAsValues)) ? $displayBlanksAs : self::DISPLAY_BLANKS_AS_GAP; } From 1cd8a46d008456d1cd5b18ae6c6b1c771bd6cdd8 Mon Sep 17 00:00:00 2001 From: tiria Date: Tue, 31 May 2016 12:49:27 +0200 Subject: [PATCH 2/3] Add dispBlanksAs and plotVisOnly values Put PHPExcel_Chart $plotVisibleOnly and $displayBlanksAs values in written chart --- Classes/PHPExcel/Writer/Excel2007/Chart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Writer/Excel2007/Chart.php b/Classes/PHPExcel/Writer/Excel2007/Chart.php index 92fa21506..d1efd843c 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Chart.php +++ b/Classes/PHPExcel/Writer/Excel2007/Chart.php @@ -87,11 +87,11 @@ public function writeChart(PHPExcel_Chart $pChart = null, $calculateCellValues = $this->writeLegend($pChart->getLegend(), $objWriter); $objWriter->startElement('c:plotVisOnly'); - $objWriter->writeAttribute('val', 1); + $objWriter->writeAttribute('val', ($pChart->getPlotVisibleOnly()) ? 1 : 0); $objWriter->endElement(); $objWriter->startElement('c:dispBlanksAs'); - $objWriter->writeAttribute('val', "gap"); + $objWriter->writeAttribute('val', $pChart->getDisplayBlanksAs()); $objWriter->endElement(); $objWriter->startElement('c:showDLblsOverMax'); From 1e3bb27009528813e0eda9f46358385b64e6d102 Mon Sep 17 00:00:00 2001 From: tiria Date: Tue, 31 May 2016 14:55:05 +0200 Subject: [PATCH 3/3] Fix error $this Error fixed : $this->displayBlanksAsValues to self::$displayBlanksAsValues in PHPExcel_Chart class --- Classes/PHPExcel/Chart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Chart.php b/Classes/PHPExcel/Chart.php index 5f904c0e1..44c9638dd 100644 --- a/Classes/PHPExcel/Chart.php +++ b/Classes/PHPExcel/Chart.php @@ -193,7 +193,7 @@ public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_ $this->yAxisLabel = $yAxisLabel; $this->plotArea = $plotArea; $this->plotVisibleOnly = $plotVisibleOnly; - $this->displayBlanksAs = (in_array($displayBlanksAs,$this->displayBlanksAsValues)) ? $displayBlanksAs : self::DISPLAY_BLANKS_AS_GAP; + $this->displayBlanksAs = (in_array($displayBlanksAs,self::$displayBlanksAsValues)) ? $displayBlanksAs : self::DISPLAY_BLANKS_AS_GAP; $this->xAxis = $xAxis; $this->yAxis = $yAxis; $this->majorGridlines = $majorGridlines; @@ -377,7 +377,7 @@ public function getDisplayBlanksAs() */ public function setDisplayBlanksAs($displayBlanksAs = self::DISPLAY_BLANKS_AS_GAP) { - $this->displayBlanksAs = (in_array($displayBlanksAs,$this->displayBlanksAsValues)) ? $displayBlanksAs : self::DISPLAY_BLANKS_AS_GAP; + $this->displayBlanksAs = (in_array($displayBlanksAs,self::$displayBlanksAsValues)) ? $displayBlanksAs : self::DISPLAY_BLANKS_AS_GAP; }