| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941 |
- <?php
- namespace PhpPresentation\Tests\Writer\PowerPoint2007;
- use \Exception;
- use PhpOffice\Common\Drawing;
- use PhpOffice\PhpPresentation\PhpPresentation;
- use PhpOffice\PhpPresentation\Shape\Chart\Axis;
- use PhpOffice\PhpPresentation\Shape\Chart\Gridlines;
- use PhpOffice\PhpPresentation\Shape\Chart\Marker;
- use PhpOffice\PhpPresentation\Shape\Chart\Series;
- use PhpOffice\PhpPresentation\Shape\Chart\Type\Area;
- use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar;
- use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D;
- use PhpOffice\PhpPresentation\Shape\Chart\Type\Line;
- use PhpOffice\PhpPresentation\Shape\Chart\Type\Pie;
- use PhpOffice\PhpPresentation\Shape\Chart\Type\Pie3D;
- use PhpOffice\PhpPresentation\Shape\Chart\Type\Scatter;
- use PhpOffice\PhpPresentation\Style\Color;
- use PhpOffice\PhpPresentation\Style\Font;
- use PhpOffice\PhpPresentation\Style\Fill;
- use PhpOffice\PhpPresentation\Style\Outline;
- use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
- class PptChartsTest extends PhpPresentationTestCase
- {
- protected $writerName = 'PowerPoint2007';
- /**
- * @var array
- */
- protected $seriesData = array(
- 'A' => 1,
- 'B' => 2,
- 'C' => 4,
- 'D' => 3,
- 'E' => 2,
- );
- /**
- * @expectedException Exception
- * @expectedExceptionMessage The chart type provided could not be rendered
- */
- public function testPlotAreaBadType()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $stub = $this->getMockForAbstractClass('PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType');
- $oShape->getPlotArea()->setType($stub);
- $this->writePresentationFile($this->oPresentation, 'PowerPoint2007');
- }
- public function testTitleVisibilityTrue()
- {
- $element = '/c:chartSpace/c:chart/c:autoTitleDeleted';
-
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oLine = new Line();
- $oShape->getPlotArea()->setType($oLine);
- // Default
- $this->assertTrue($oShape->getTitle()->isVisible());
- // Set Visible : TRUE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(true));
- $this->assertTrue($oShape->getTitle()->isVisible());
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '0');
- }
- public function testTitleVisibilityFalse()
- {
- $element = '/c:chartSpace/c:chart/c:autoTitleDeleted';
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oLine = new Line();
- $oShape->getPlotArea()->setType($oLine);
- // Set Visible : FALSE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Title', $oShape->getTitle()->setVisible(false));
- $this->assertFalse($oShape->getTitle()->isVisible());
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '1');
- }
- public function testAxisFont()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oBar = new Bar();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oBar->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oBar);
- $oShape->getPlotArea()->getAxisX()->getFont()->getColor()->setRGB('AABBCC');
- $oShape->getPlotArea()->getAxisX()->getFont()->setItalic(true);
- $oShape->getPlotArea()->getAxisX()->getFont()->setStrikethrough(true);
- $oShape->getPlotArea()->getAxisY()->getFont()->getColor()->setRGB('00FF00');
- $oShape->getPlotArea()->getAxisY()->getFont()->setSize(16);
- $oShape->getPlotArea()->getAxisY()->getFont()->setUnderline(Font::UNDERLINE_DASH);
- $pathShape = 'ppt/charts/' . $oShape->getIndexedFilename();
- $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr';
- $this->assertZipXmlElementExists($pathShape, $element);
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'val', 'AABBCC');
- $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists($pathShape, $element);
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'i', 'true');
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'sz', 1000);
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'strike', 'sngStrike');
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'u', Font::UNDERLINE_NONE);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr';
- $this->assertZipXmlElementExists($pathShape, $element);
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'val', '00FF00');
- $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists($pathShape, $element);
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'i', 'false');
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'sz', 1600);
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'strike', 'noStrike');
- $this->assertZipXmlAttributeEquals($pathShape, $element, 'u', Font::UNDERLINE_DASH);
- }
- public function testAxisOutline()
- {
- $expectedWidthX = 2;
- $expectedColorX = 'ABCDEF';
- $expectedWidthY = 4;
- $expectedColorY = '012345';
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oBar = new Bar();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oBar->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oBar);
- $oShape->getPlotArea()->getAxisX()->getOutline()->setWidth($expectedWidthX);
- $oShape->getPlotArea()->getAxisX()->getOutline()->getFill()->setFillType(Fill::FILL_SOLID);
- $oShape->getPlotArea()->getAxisX()->getOutline()->getFill()->getStartColor()->setRGB($expectedColorX);
- $oShape->getPlotArea()->getAxisY()->getOutline()->setWidth($expectedWidthY);
- $oShape->getPlotArea()->getAxisY()->getOutline()->getFill()->setFillType(Fill::FILL_SOLID);
- $oShape->getPlotArea()->getAxisY()->getOutline()->getFill()->getStartColor()->setRGB($expectedColorY);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidthX)));
- $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorX);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidthY)));
- $element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorY);
- }
- public function testAxisVisibilityFalse()
- {
- $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:delete';
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oLine = new Line();
- $oShape->getPlotArea()->setType($oLine);
- // Set Visible : FALSE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(false));
- $this->assertFalse($oShape->getPlotArea()->getAxisX()->isVisible());
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '1');
- }
- public function testAxisVisibilityTrue()
- {
- $element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:delete';
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oLine = new Line();
- $oShape->getPlotArea()->setType($oLine);
- // Set Visible : TRUE
- $this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(true));
- $this->assertTrue($oShape->getPlotArea()->getAxisX()->isVisible());
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '0');
- }
- public function testTypeArea()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oArea = new Area();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
- $oArea->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oArea);
- $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
- $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- }
- public function testTypeAxisBounds()
- {
- $value = rand(0, 100);
- $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);
- $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);
- $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);
- $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);
- }
- public function testTypeAxisTickMark()
- {
- $value = Axis::TICK_MARK_CROSS;
- $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:valAx/c:majorTickMark';
- $elementMin = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:minorTickMark';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', Axis::TICK_MARK_NONE);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', Axis::TICK_MARK_NONE);
- $oShape->getPlotArea()->getAxisY()->setMinorTickMark($value);
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', Axis::TICK_MARK_NONE);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', $value);
- $oShape->getPlotArea()->getAxisY()->setMinorTickMark();
- $oShape->getPlotArea()->getAxisY()->setMajorTickMark($value);
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin, 'val', Axis::TICK_MARK_NONE);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax, 'val', $value);
- $oShape->getPlotArea()->getAxisY()->setMinorTickMark($value);
- $oShape->getPlotArea()->getAxisY()->setMajorTickMark($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);
- }
- public function testTypeAxisUnit()
- {
- $value = rand(0, 100);
- $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:valAx/c:majorUnit';
- $elementMin = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:minorUnit';
- $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMax);
- $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $elementMin);
- $oShape->getPlotArea()->getAxisY()->setMinorUnit($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);
- $oShape->getPlotArea()->getAxisY()->setMinorUnit(null);
- $oShape->getPlotArea()->getAxisY()->setMajorUnit($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);
- $oShape->getPlotArea()->getAxisY()->setMinorUnit($value);
- $oShape->getPlotArea()->getAxisY()->setMajorUnit($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);
- }
- public function testTypeBar()
- {
- $valueGapWidthPercent = rand(0, 500);
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oBar = new Bar();
- $oBar->setGapWidthPercent($valueGapWidthPercent);
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
- $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
- $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
- $oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
- $oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
- $oBar->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oBar);
- $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
- $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt/c:spPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:tx/c:v';
- $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle());
- $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:gapWidth';
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $valueGapWidthPercent);
- }
- public function testTypeBar3D()
- {
- $valueGapWidthPercent = rand(0, 500);
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oBar3D = new Bar3D();
- $oBar3D->setGapWidthPercent($valueGapWidthPercent);
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
- $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
- $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
- $oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
- $oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
- $oBar3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oBar3D);
- $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
- $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:dPt/c:spPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:tx/c:v';
- $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle());
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:gapWidth';
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $valueGapWidthPercent);
- }
- public function testTypeBar3DSubScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oBar3D = new Bar3D();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSubScript(true);
- $oBar3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oBar3D);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '-25000');
- }
- public function testTypeBar3DSuperScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oBar3D = new Bar3D();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSuperScript(true);
- $oBar3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oBar3D);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '30000');
- }
- public function testTypeBar3DBarDirection()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oBar3D = new Bar3D();
- $oBar3D->setBarDirection(Bar3D::DIRECTION_HORIZONTAL);
- $oSeries = new Series('Downloads', $this->seriesData);
- $oBar3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oBar3D);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:barDir';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', Bar3D::DIRECTION_HORIZONTAL);
- }
- public function testTypeLine()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oLine = new Line();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oLine->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oLine);
- $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
- $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:tx/c:v';
- $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle());
- }
- public function testTypeLineGridlines()
- {
- $arrayTests = array(
- array(
- 'methodAxis' => 'getAxisX',
- 'methodGrid' => 'setMajorGridlines',
- 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:majorGridlines/c:spPr/a:ln',
- 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:majorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr',
- ),
- array(
- 'methodAxis' => 'getAxisX',
- 'methodGrid' => 'setMinorGridlines',
- 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:minorGridlines/c:spPr/a:ln',
- 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:minorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr',
- ),
- array(
- 'methodAxis' => 'getAxisY',
- 'methodGrid' => 'setMajorGridlines',
- 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:majorGridlines/c:spPr/a:ln',
- 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:majorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr',
- ),
- array(
- 'methodAxis' => 'getAxisY',
- 'methodGrid' => 'setMinorGridlines',
- 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:minorGridlines/c:spPr/a:ln',
- 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:minorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr',
- ),
- );
- $expectedColor = new Color(Color::COLOR_BLUE);
- foreach ($arrayTests as $arrayTest) {
- $expectedSizePts = rand(1, 100);
- $expectedSizeEmu = round(Drawing::pointsToPixels(Drawing::pixelsToEmu($expectedSizePts)));
- $this->oPresentation->removeSlideByIndex()->createSlide();
- $oShape = $this->oPresentation->getActiveSlide()->createChartShape();
- $oLine = new Line();
- $oLine->addSeries(new Series('Downloads', array(
- 'A' => 1,
- 'B' => 2,
- 'C' => 4,
- 'D' => 3,
- 'E' => 2,
- )));
- $oShape->getPlotArea()->setType($oLine);
- $oGridlines = new Gridlines();
- $oGridlines->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor($expectedColor);
- $oGridlines->getOutline()->setWidth($expectedSizePts);
- $oShape->getPlotArea()->{$arrayTest['methodAxis']}()->{$arrayTest['methodGrid']}($oGridlines);
- $this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $arrayTest['expectedElement']);
- $this->assertZipXmlAttributeExists('ppt/charts/' . $oShape->getIndexedFilename(), $arrayTest['expectedElement'], 'w');
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $arrayTest['expectedElement'], 'w', $expectedSizeEmu);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $arrayTest['expectedElementColor']);
- $this->assertZipXmlAttributeExists('ppt/charts/' . $oShape->getIndexedFilename(), $arrayTest['expectedElementColor'], 'val');
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $arrayTest['expectedElementColor'], 'val', $expectedColor->getRGB());
- $this->resetPresentationFile();
- }
- }
- public function testTypeLineMarker()
- {
- do {
- $expectedSymbol = array_rand(Marker::$arraySymbol);
- } while ($expectedSymbol == Marker::SYMBOL_NONE);
- $expectedSize = rand(2, 72);
- $expectedEltSymbol = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:marker/c:symbol';
- $expectedElementSize = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:marker/c:size';
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oLine = new Line();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getMarker()->setSymbol($expectedSymbol)->setSize($expectedSize);
- $oLine->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oLine);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedEltSymbol);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedEltSymbol, 'val', $expectedSymbol);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize, 'val', $expectedSize);
- $oSeries->getMarker()->setSize(1);
- $oLine->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize, 'val', 2);
- $oSeries->getMarker()->setSize(73);
- $oLine->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize, 'val', 72);
- $oSeries->getMarker()->setSymbol(Marker::SYMBOL_NONE);
- $oLine->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedEltSymbol);
- $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- }
- public function testTypeLineSeriesOutline()
- {
- $expectedWidth = rand(1, 100);
- $expectedWidthEmu = Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidth));
- $expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:spPr/a:ln';
- $oOutline = new Outline();
- $oOutline->getFill()->setFillType(Fill::FILL_SOLID);
- $oOutline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));
- $oOutline->setWidth($expectedWidth);
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oLine = new Line();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oLine->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oLine);
- $this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
- $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
- $oSeries->setOutline($oOutline);
- $oLine->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement, 'w', $expectedWidthEmu);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement . '/a:solidFill');
- }
- public function testTypeLineSubScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oLine = new Line();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSubScript(true);
- $oLine->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oLine);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '-25000');
- }
- public function testTypeLineSuperScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oLine = new Line();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSuperScript(true);
- $oLine->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oLine);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '30000');
- }
- public function testTypePie()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oPie = new Pie();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
- $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
- $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
- $oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
- $oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
- $oPie->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oPie);
- $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
- $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dPt/c:spPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:tx/c:v';
- $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle());
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:showLegendKey';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 0);
- $oSeries->setShowLegendKey(true);
- $this->resetPresentationFile();
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:showLegendKey';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 1);
- }
- public function testTypePieSeparator()
- {
- $value = ';';
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oPie = new Pie();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oPie->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oPie);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:separator';
- $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $oSeries->setSeparator($value);
- $this->resetPresentationFile();
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:separator';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $value);
- }
- public function testTypePie3D()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oPie3D = new Pie3D();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
- $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
- $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
- $oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
- $oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
- $oPie3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oPie3D);
- $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
- $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pie3DChart';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser/c:dPt/c:spPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser/c:tx/c:v';
- $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle());
- }
- public function testTypePie3DExplosion()
- {
- $value = rand(1, 100);
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oPie3D = new Pie3D();
- $oPie3D->setExplosion($value);
- $oSeries = new Series('Downloads', $this->seriesData);
- $oPie3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oPie3D);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser/c:explosion';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $value);
- }
- public function testTypePie3DSubScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oPie3D = new Pie3D();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSubScript(true);
- $oPie3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oPie3D);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '-25000');
- }
- public function testTypePie3DSuperScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oPie3D = new Pie3D();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSuperScript(true);
- $oPie3D->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oPie3D);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '30000');
- }
- public function testTypeScatter()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oScatter = new Scatter();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oScatter->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oScatter);
- $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
- $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:tx/c:v';
- $this->assertZipXmlElementEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, $oSeries->getTitle());
- $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:dLbls/c:showLegendKey';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 0);
- $oSeries->setShowLegendKey(true);
- $this->resetPresentationFile();
- $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:dLbls/c:showLegendKey';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', 1);
- }
- public function testTypeScatterMarker()
- {
- do {
- $expectedSymbol = array_rand(Marker::$arraySymbol);
- } while ($expectedSymbol == Marker::SYMBOL_NONE);
- $expectedSize = rand(2, 72);
- $expectedEltSymbol = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:marker/c:symbol';
- $expectedElementSize = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:marker/c:size';
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oScatter = new Scatter();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getMarker()->setSymbol($expectedSymbol)->setSize($expectedSize);
- $oScatter->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oScatter);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedEltSymbol);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedEltSymbol, 'val', $expectedSymbol);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize, 'val', $expectedSize);
- $oSeries->getMarker()->setSize(1);
- $oScatter->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize, 'val', 2);
- $oSeries->getMarker()->setSize(73);
- $oScatter->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize, 'val', 72);
- $oSeries->getMarker()->setSymbol(Marker::SYMBOL_NONE);
- $oScatter->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedEltSymbol);
- $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElementSize);
- }
- public function testTypeScatterSeriesOutline()
- {
- $expectedWidth = rand(1, 100);
- $expectedWidthEmu = Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidth));
- $expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:spPr/a:ln';
- $oOutline = new Outline();
- // Define the color
- $oOutline->getFill()->setFillType(Fill::FILL_SOLID);
- $oOutline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));
- // Define the width (in points)
- $oOutline->setWidth($expectedWidth);
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oScatter = new Scatter();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oScatter->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oScatter);
- $this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
- $this->assertZipXmlElementNotExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
- $oSeries->setOutline($oOutline);
- $oScatter->setSeries(array($oSeries));
- $this->resetPresentationFile();
- $this->assertZipFileExists('ppt/charts/' . $oShape->getIndexedFilename());
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement, 'w', $expectedWidthEmu);
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $expectedElement . '/a:solidFill');
- }
- public function testTypeScatterSubScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oScatter = new Scatter();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSubScript(true);
- $oScatter->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oScatter);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
- $this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'baseline', '-25000');
- }
- public function testTypeScatterSuperScript()
- {
- $oSlide = $this->oPresentation->getActiveSlide();
- $oShape = $oSlide->createChartShape();
- $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
- $oScatter = new Scatter();
- $oSeries = new Series('Downloads', $this->seriesData);
- $oSeries->getFont()->setSuperScript(true);
- $oScatter->addSeries($oSeries);
- $oShape->getPlotArea()->setType($oScatter);
- $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
- $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);
- }
- }
|