diff --git a/src/PhpWord/Style/Chart.php b/src/PhpWord/Style/Chart.php index 6cffc4d5b0..d2850935f5 100644 --- a/src/PhpWord/Style/Chart.php +++ b/src/PhpWord/Style/Chart.php @@ -149,6 +149,34 @@ class Chart extends AbstractStyle */ private $gridX = false; + /** + * Min value for Y-Axis. + * + * @var null|float|int + */ + private $minY; + + /** + * Max value for X-Axis. + * + * @var null|float|int + */ + private $minX; + + /** + * Max value for Y-Axis. + * + * @var null|float|int + */ + private $maxY; + + /** + * Max value for X-Axis. + * + * @var null|float|int + */ + private $maxX; + /** * Create a new instance. * @@ -551,4 +579,68 @@ public function setShowGridX($value = true) return $this; } + + /** + * @return null|float|int + */ + public function minY() + { + return $this->minY; + } + + /** + * @param null|float|int $minY + */ + public function setMinY($minY): void + { + $this->minY = $minY; + } + + /** + * @return null|float|int + */ + public function minX() + { + return $this->minX; + } + + /** + * @param null|float|int $minX + */ + public function setMinX($minX): void + { + $this->minX = $minX; + } + + /** + * @return null|float|int + */ + public function maxY() + { + return $this->maxY; + } + + /** + * @param null|float|int $maxY + */ + public function setMaxY($maxY): void + { + $this->maxY = $maxY; + } + + /** + * @return null|float|int + */ + public function maxX() + { + return $this->maxX; + } + + /** + * @param null|float|int $maxX + */ + public function setMaxX($maxX): void + { + $this->maxX = $maxX; + } } diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index 65e686ebad..218d6885f6 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -387,6 +387,26 @@ private function writeAxis(XMLWriter $xmlWriter, $type): void $xmlWriter->startElement('c:scaling'); $xmlWriter->writeElementBlock('c:orientation', 'val', 'minMax'); + if ($type == 'cat' && $style->minX()) { + $xmlWriter->startElement('c:min'); + $xmlWriter->writeAttribute('val', $style->minX()); + $xmlWriter->endElement(); + } + if ($type == 'cat' && $style->maxX()) { + $xmlWriter->startElement('c:max'); + $xmlWriter->writeAttribute('val', $style->maxX()); + $xmlWriter->endElement(); + } + if ($type == 'val' && $style->minY()) { + $xmlWriter->startElement('c:min'); + $xmlWriter->writeAttribute('val', $style->minY()); + $xmlWriter->endElement(); + } + if ($type == 'val' && $style->maxY()) { + $xmlWriter->startElement('c:max'); + $xmlWriter->writeAttribute('val', $style->maxY()); + $xmlWriter->endElement(); + } $xmlWriter->endElement(); // c:scaling $this->writeShape($xmlWriter, true);