Get plotVisOnly and dispBlanksAs props from chart in Xlsx Chart Writer.

These chart properties where hardcoded in the Xlsx writer, ignoring the
values passed to the \PhpOffice\PhpSpreadsheet\Chart\Chart class constructor.

I also changed the default $displayBlanksAs value to 'gap' to match this
document:
https://docs.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/1942c028-3c4e-4dd9-a379-b12a9b7914df

Closes #1266
This commit is contained in:
Guilherme Capanema 2019-11-29 11:27:48 -03:00 committed by Adrien Crivelli
parent d61855effe
commit 144a0cabbc
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
3 changed files with 4 additions and 3 deletions

View File

@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Do not confuse defined names and cell refs [#1263](https://github.com/PHPOffice/PhpSpreadsheet/pull/1263)
- XLSX reader/writer keep decimal for floats with a zero decimal part [#1262](https://github.com/PHPOffice/PhpSpreadsheet/pull/1262)
- ODS writer prevent invalid numeric value if locale decimal separator is comma [#1268](https://github.com/PHPOffice/PhpSpreadsheet/pull/1268)
- Xlsx writer actually writes plotVisOnly and dispBlanksAs from chart properties [#1266](https://github.com/PHPOffice/PhpSpreadsheet/pull/1266)
## [1.10.0] - 2019-11-18

View File

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

View File

@ -83,11 +83,11 @@ class Chart extends WriterPart
$this->writeLegend($objWriter, $pChart->getLegend());
$objWriter->startElement('c:plotVisOnly');
$objWriter->writeAttribute('val', 1);
$objWriter->writeAttribute('val', (int) $pChart->getPlotVisibleOnly());
$objWriter->endElement();
$objWriter->startElement('c:dispBlanksAs');
$objWriter->writeAttribute('val', 'gap');
$objWriter->writeAttribute('val', $pChart->getDisplayBlanksAs());
$objWriter->endElement();
$objWriter->startElement('c:showDLblsOverMax');