diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php index 4d03776f1..9c8c2251e 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php @@ -2319,13 +2319,13 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty $objWriter->writeAttribute('val', $orientation); $objWriter->endElement(); - if (null != $oAxis->getMaxBounds()) { + if (null !== $oAxis->getMaxBounds()) { $objWriter->startElement('c:max'); $objWriter->writeAttribute('val', $oAxis->getMaxBounds()); $objWriter->endElement(); } - if (null != $oAxis->getMinBounds()) { + if (null !== $oAxis->getMinBounds()) { $objWriter->startElement('c:min'); $objWriter->writeAttribute('val', $oAxis->getMinBounds()); $objWriter->endElement(); diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php index aba15710f..221c7f4e4 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php @@ -229,6 +229,57 @@ public function testTitleVisibilityFalse(): void public function testAxisBounds(): void { $value = mt_rand(0, 100); + $value = 0; + + $oSeries = new Series('Downloads', $this->seriesData); + $oSeries->getFill()->setStartColor(new Color('FFAABBCC')); + $oLine = new Line(); + $oLine->addSeries($oSeries); + $oShape = $this->oPresentation->getActiveSlide()->createChartShape(); + $oShape->getPlotArea()->setType($oLine); + + $elementMax = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:max'; + $elementMin = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:scaling/c:min'; + + $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax); + $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin); + + $this->assertIsSchemaECMA376Valid(); + + $oShape->getPlotArea()->getAxisX()->setMinBounds($value); + $this->resetPresentationFile(); + + $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax); + $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value); + + $this->assertIsSchemaECMA376Valid(); + + $oShape->getPlotArea()->getAxisX()->setMinBounds(null); + $oShape->getPlotArea()->getAxisX()->setMaxBounds($value); + $this->resetPresentationFile(); + + $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin); + $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value); + + $this->assertIsSchemaECMA376Valid(); + + $oShape->getPlotArea()->getAxisX()->setMinBounds($value); + $oShape->getPlotArea()->getAxisX()->setMaxBounds($value); + $this->resetPresentationFile(); + + $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value); + $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax); + $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value); + + $this->assertIsSchemaECMA376Valid(); + } + + public function testAxisBoundsIfZero(): void + { + $value = 0; $oSeries = new Series('Downloads', $this->seriesData); $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));