public function testHashCode() { $oSeries = new Series(); $object = new Line(); $object->addSeries($oSeries); $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode()); }
public function testLegend() { $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2)); $oSeries->setShowSeriesName(true); $oLine = new Line(); $oLine->addSeries($oSeries); $phpPresentation = new PhpPresentation(); $oSlide = $phpPresentation->getActiveSlide(); $oChart = $oSlide->createChartShape(); $oChart->getPlotArea()->setType($oLine); $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation'); $element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell[@office:value-type=\'string\']'; $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml')); }
$oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20')); $oShadow = new Shadow(); $oShadow->setVisible(true)->setDirection(45)->setDistance(10); // 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($objPHPPresentation); // Create a line chart (that should be inserted in a shape) echo date('H:i:s') . ' Create a line chart (that should be inserted in a chart shape)' . EOL; $lineChart = new Line(); $series = new Series('Downloads', $seriesData); $series->setShowSeriesName(true); $series->setShowValue(true); $lineChart->addSeries($series); // Create a shape (chart) echo date('H:i:s') . ' Create a shape (chart)' . EOL; $shape = $currentSlide->createChartShape(); $shape->setName('PHPPresentation 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('PHPPresentation Daily Downloads'); $shape->getTitle()->getFont()->setItalic(true); $shape->getPlotArea()->setType($lineChart); $shape->getView3D()->setRotationX(30); $shape->getView3D()->setPerspective(30); $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE); $shape->getLegend()->getFont()->setItalic(true); // Create templated slide
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); $oXMLDoc = TestHelperDOCX::getDocument($this->oPresentation, 'PowerPoint2007'); $element = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr'; $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename())); $this->assertEquals('30000', $oXMLDoc->getElementAttribute($element, 'baseline', 'ppt/charts/' . $oShape->getIndexedFilename())); }
public function testTypeLineSeriesOutline() { $expectedWidth = rand(1, 100); $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm'; $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties'; $oColor = new Color(Color::COLOR_YELLOW); $oOutline = new Outline(); // Define the color $oOutline->getFill()->setFillType(Fill::FILL_SOLID); $oOutline->getFill()->setStartColor($oColor); // Define the width (in points) $oOutline->setWidth($expectedWidth); $oPhpPresentation = new PhpPresentation(); $oSlide = $oPhpPresentation->getActiveSlide(); $oShape = $oSlide->createChartShape(); $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80); $oLine = new Line(); $oSeries = new Series('Downloads', array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2)); $oLine->addSeries($oSeries); $oShape->getPlotArea()->setType($oLine); $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation'); $this->assertTrue($oXMLDoc->fileExists('Object 1/content.xml')); $this->assertTrue($oXMLDoc->elementExists($expectedElement, 'Object 1/content.xml')); $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-width', 'Object 1/content.xml')); $this->assertEquals('0.079cm', $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-width', 'Object 1/content.xml')); $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-color', 'Object 1/content.xml')); $this->assertEquals('#4a7ebb', $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-color', 'Object 1/content.xml')); $oSeries->setOutline($oOutline); $oLine->setSeries(array($oSeries)); $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation'); $this->assertTrue($oXMLDoc->fileExists('Object 1/content.xml')); $this->assertTrue($oXMLDoc->elementExists($expectedElement, 'Object 1/content.xml')); $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-width', 'Object 1/content.xml')); $this->assertEquals($expectedWidthCm, $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-width', 'Object 1/content.xml')); $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-color', 'Object 1/content.xml')); $this->assertEquals('#' . $oColor->getRGB(), $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-color', 'Object 1/content.xml')); }