diff --git a/Classes/PHPExcel/Chart.php b/Classes/PHPExcel/Chart.php index d7799935b..44c9638dd 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,self::$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,self::$displayBlanksAsValues)) ? $displayBlanksAs : self::DISPLAY_BLANKS_AS_GAP; } 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');