Skip to content

Commit 97ffc75

Browse files
committed
#293 : PowerPoint2007 Writer : Support autoscale for Chart
1 parent 3d9d26c commit 97ffc75

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- PowerPoint2007 Writer : Support text direction in Alignment for Table - @SeregPie GH-218
2626
- PowerPoint2007 Writer : Support tick mark & unit in Axis for Chart - @Faab GH-218
2727
- PowerPoint2007 Writer : Support separator in Series for Chart - @jphchaput GH-218
28+
- PowerPoint2007 Writer : Support autoscale for Chart - @Progi1984 GH-293
2829
- Misc : Added two methods for setting Border & Fill in Legend - @Progi1984 GH-265
2930

3031
## 0.7.0 - 2016-09-12

docs/shapes_chart.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ You can define if some informations are displayed.
145145
$oSeries->setShowSeriesName(true);
146146
$oSeries->setShowValue(true);
147147
148+
View3D
149+
^^^^^^
150+
151+
For enabling the autoscale for a shape, you must reset the height percent.
152+
153+
.. code-block:: php
154+
155+
$oShape->getView3D()->setHeightPercent(null);
156+
148157
Types
149158
-----
150159

src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,15 @@ public function writeChart(Chart $chart)
9797
$objWriter->writeAttribute('val', $chart->getView3D()->getRotationX());
9898
$objWriter->endElement();
9999

100-
// c:hPercent
101-
$objWriter->startElement('c:hPercent');
102-
$objWriter->writeAttribute('val', $chart->getView3D()->getHeightPercent());
103-
$objWriter->endElement();
104-
105100
// c:rotY
106101
$objWriter->startElement('c:rotY');
107102
$objWriter->writeAttribute('val', $chart->getView3D()->getRotationY());
108103
$objWriter->endElement();
109104

105+
// c:hPercent
106+
$hPercent = $chart->getView3D()->getHeightPercent();
107+
$objWriter->writeElementIf($hPercent != null, 'c:hPercent', 'val', $hPercent);
108+
110109
// c:depthPercent
111110
$objWriter->startElement('c:depthPercent');
112111
$objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent());

tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptChartsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,4 +843,22 @@ public function testTypeScatterSuperScript()
843843
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
844844
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '30000');
845845
}
846+
847+
public function testView3D()
848+
{
849+
$oSlide = $this->oPresentation->getActiveSlide();
850+
$oLine = new Line();
851+
$oLine->addSeries(new Series('Downloads', $this->seriesData));
852+
$oShape = $oSlide->createChartShape();
853+
$oShape->getPlotArea()->setType($oLine);
854+
855+
$element = '/c:chartSpace/c:chart/c:view3D/c:hPercent';
856+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
857+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 100);
858+
859+
$oShape->getView3D()->setHeightPercent(null);
860+
$this->resetPresentationFile();
861+
862+
$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
863+
}
846864
}

0 commit comments

Comments
 (0)