Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Really adding displayBlanksAs for charts #911

Open
wants to merge 3 commits into
base: 1.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions Classes/PHPExcel/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -88,7 +103,7 @@ class PHPExcel_Chart
*
* @var string
*/
private $displayBlanksAs = '0';
private $displayBlanksAs = self::DISPLAY_BLANKS_AS_GAP;

/**
* Chart Asix Y as
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}


Expand Down
4 changes: 2 additions & 2 deletions Classes/PHPExcel/Writer/Excel2007/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down