function fnSlide_Area(PhpPowerpoint $objPHPPowerPoint) { global $oFill; global $oShadow; // Generate sample data for chart echo date('H:i:s') . ' Generate sample data for chart' . EOL; $seriesData = array('Monday' => 12, 'Tuesday' => 15, 'Wednesday' => 13, 'Thursday' => 17, 'Friday' => 14, 'Saturday' => 9, 'Sunday' => 7); // Create templated slide echo EOL . date('H:i:s') . ' Create templated slide' . EOL; $currentSlide = createTemplatedSlide($objPHPPowerPoint); // Create a line chart (that should be inserted in a shape) echo date('H:i:s') . ' Create a area chart (that should be inserted in a chart shape)' . EOL; $areaChart = new Area(); $series = new Series('Downloads', $seriesData); $series->setShowSeriesName(true); $series->setShowValue(true); $series->getFill()->setStartColor(new Color('FF93A9CE')); $areaChart->addSeries($series); // Create a shape (chart) echo date('H:i:s') . ' Create a shape (chart)' . EOL; $shape = $currentSlide->createChartShape(); $shape->getTitle()->setVisible(false); $shape->setName('PHPPowerPoint Daily Downloads')->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80); $shape->setShadow($oShadow); $shape->setFill($oFill); $shape->getBorder()->setLineStyle(Border::LINE_SINGLE); $shape->getTitle()->setText('PHPPowerPoint Daily Downloads'); $shape->getTitle()->getFont()->setItalic(true); $shape->getPlotArea()->setType($areaChart); $shape->getView3D()->setRotationX(30); $shape->getView3D()->setPerspective(30); $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE); $shape->getLegend()->getFont()->setItalic(true); }
public function testHashCode() { $oSeries = new Series(); $object = new Area(); $object->addSeries($oSeries); $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode()); }
public function testTypeArea() { $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2); $oPHPPowerPoint = new PhpPowerpoint(); $oSlide = $oPHPPowerPoint->getActiveSlide(); $oShape = $oSlide->createChartShape(); $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80); $oArea = new Area(); $oSeries = new Series('Downloads', $seriesData); $oSeries->getFill()->setStartColor(new Color('FFAABBCC')); $oArea->addSeries($oSeries); $oShape->getPlotArea()->setType($oArea); $oXMLDoc = TestHelperDOCX::getDocument($oPHPPowerPoint, 'PowerPoint2007'); $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData'; $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml')); $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart'; $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename())); $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser'; $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename())); }
public function testChartArea() { $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2)); $oSeries->getFill()->setStartColor(new Color('FF93A9CE')); $oArea = new Area(); $oArea->addSeries($oSeries); $phpPowerPoint = new PhpPowerpoint(); $oSlide = $phpPowerPoint->getActiveSlide(); $oChart = $oSlide->createChartShape(); $oChart->getPlotArea()->setType($oArea); $pres = TestHelperDOCX::getDocument($phpPowerPoint, 'ODPresentation'); $element = '/office:document-content/office:body/office:chart/chart:chart'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml')); $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml')); $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\']/style:graphic-properties'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); $this->assertFalse($pres->attributeElementExists($element, 'draw:fill', 'Object 1/content.xml')); $this->assertTrue($pres->attributeElementExists($element, 'draw:fill-color', 'Object 1/content.xml')); $this->assertEquals('#93A9CE', $pres->getElementAttribute($element, 'draw:fill-color', 'Object 1/content.xml')); }