File containing a chart can be opened by Excel 2003/2013/2019

All chart examples passed the displayBlanksAs parameter as 0 instead of 'gap'.
I added a constants EMPTY_AS_GAP, EMPTY_AS_ZERO and EMPTY_AS_SPAN to the
DataSeries and then change all chart samples to use this new constant.

Fixes #1337
Closes #1448
This commit is contained in:
Chris Wolcott 2020-04-18 10:37:45 -04:00 committed by Adrien Crivelli
parent c725128a68
commit d49567aad0
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
15 changed files with 18 additions and 14 deletions

View File

@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed ### Fixed
- ... - Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](https://github.com/PHPOffice/PhpSpreadsheet/pull/1448)
### Changed ### Changed

View File

@ -83,7 +83,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );

View File

@ -86,7 +86,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );

View File

@ -86,7 +86,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );

View File

@ -95,7 +95,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
$xAxisLabel, // xAxisLabel $xAxisLabel, // xAxisLabel
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );

View File

@ -139,7 +139,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
null // yAxisLabel null // yAxisLabel
); );

View File

@ -84,7 +84,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );

View File

@ -158,7 +158,7 @@ $chart2 = new Chart(
$legend2, // legend $legend2, // legend
$plotArea2, // plotArea $plotArea2, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
$yAxisLabel2 // yAxisLabel $yAxisLabel2 // yAxisLabel
); );

View File

@ -84,7 +84,7 @@ $chart1 = new Chart(
$legend1, // legend $legend1, // legend
$plotArea1, // plotArea $plotArea1, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
null // yAxisLabel - Pie charts don't have a Y-Axis null // yAxisLabel - Pie charts don't have a Y-Axis
); );

View File

@ -162,7 +162,7 @@ $chart2 = new Chart(
null, // legend null, // legend
$plotArea2, // plotArea $plotArea2, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
null // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis null // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis
); );

View File

@ -96,7 +96,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
null // yAxisLabel - Radar charts don't have a Y-Axis null // yAxisLabel - Radar charts don't have a Y-Axis
); );

View File

@ -80,7 +80,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
null, // xAxisLabel null, // xAxisLabel
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );

View File

@ -92,7 +92,7 @@ $chart = new Chart(
$legend, // legend $legend, // legend
$plotArea, // plotArea $plotArea, // plotArea
true, // plotVisibleOnly true, // plotVisibleOnly
0, // displayBlanksAs DataSeries::EMPTY_AS_GAP, // displayBlanksAs
$xAxisLabel, // xAxisLabel $xAxisLabel, // xAxisLabel
$yAxisLabel // yAxisLabel $yAxisLabel // yAxisLabel
); );

View File

@ -156,7 +156,7 @@ class Chart
* @param null|GridLines $majorGridlines * @param null|GridLines $majorGridlines
* @param null|GridLines $minorGridlines * @param null|GridLines $minorGridlines
*/ */
public function __construct($name, Title $title = null, Legend $legend = null, PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = 'gap', Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null) public function __construct($name, Title $title = null, Legend $legend = null, PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, Title $xAxisLabel = null, Title $yAxisLabel = null, Axis $xAxis = null, Axis $yAxis = null, GridLines $majorGridlines = null, GridLines $minorGridlines = null)
{ {
$this->name = $name; $this->name = $name;
$this->title = $title; $this->title = $title;

View File

@ -40,6 +40,10 @@ class DataSeries
const STYLE_MARKER = 'marker'; const STYLE_MARKER = 'marker';
const STYLE_FILLED = 'filled'; const STYLE_FILLED = 'filled';
const EMPTY_AS_GAP = 'gap';
const EMPTY_AS_ZERO = 'zero';
const EMPTY_AS_SPAN = 'span';
/** /**
* Series Plot Type. * Series Plot Type.
* *