Skip to content

Commit

Permalink
PHPOffice#293 : PowerPoint2007 Writer : Support autoscale for Chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Mar 6, 2017
1 parent 3d9d26c commit 97ffc75
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- PowerPoint2007 Writer : Support text direction in Alignment for Table - @SeregPie GH-218
- PowerPoint2007 Writer : Support tick mark & unit in Axis for Chart - @Faab GH-218
- PowerPoint2007 Writer : Support separator in Series for Chart - @jphchaput GH-218
- PowerPoint2007 Writer : Support autoscale for Chart - @Progi1984 GH-293
- Misc : Added two methods for setting Border & Fill in Legend - @Progi1984 GH-265

## 0.7.0 - 2016-09-12
Expand Down
9 changes: 9 additions & 0 deletions docs/shapes_chart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ You can define if some informations are displayed.
$oSeries->setShowSeriesName(true);
$oSeries->setShowValue(true);
View3D
^^^^^^

For enabling the autoscale for a shape, you must reset the height percent.

.. code-block:: php
$oShape->getView3D()->setHeightPercent(null);
Types
-----

Expand Down
9 changes: 4 additions & 5 deletions src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ public function writeChart(Chart $chart)
$objWriter->writeAttribute('val', $chart->getView3D()->getRotationX());
$objWriter->endElement();

// c:hPercent
$objWriter->startElement('c:hPercent');
$objWriter->writeAttribute('val', $chart->getView3D()->getHeightPercent());
$objWriter->endElement();

// c:rotY
$objWriter->startElement('c:rotY');
$objWriter->writeAttribute('val', $chart->getView3D()->getRotationY());
$objWriter->endElement();

// c:hPercent
$hPercent = $chart->getView3D()->getHeightPercent();
$objWriter->writeElementIf($hPercent != null, 'c:hPercent', 'val', $hPercent);

// c:depthPercent
$objWriter->startElement('c:depthPercent');
$objWriter->writeAttribute('val', $chart->getView3D()->getDepthPercent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,4 +843,22 @@ public function testTypeScatterSuperScript()
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '30000');
}

public function testView3D()
{
$oSlide = $this->oPresentation->getActiveSlide();
$oLine = new Line();
$oLine->addSeries(new Series('Downloads', $this->seriesData));
$oShape = $oSlide->createChartShape();
$oShape->getPlotArea()->setType($oLine);

$element = '/c:chartSpace/c:chart/c:view3D/c:hPercent';
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 100);

$oShape->getView3D()->setHeightPercent(null);
$this->resetPresentationFile();

$this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
}
}

0 comments on commit 97ffc75

Please sign in to comment.