Example #1
0
 public function testHashCode()
 {
     $oSeries = new Series();
     $object = new Scatter();
     $object->addSeries($oSeries);
     $this->assertEquals(md5($oSeries->getHashCode() . get_class($object)), $object->getHashCode());
 }
Example #2
0
 public function testChartScatter()
 {
     $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
     $oSeries->setShowSeriesName(true);
     $oScatter = new Scatter();
     $oScatter->addSeries($oSeries);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oChart = $oSlide->createChartShape();
     $oChart->getPlotArea()->setType($oScatter);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:chart/chart:chart';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:scatter', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
 }
function fnSlide_Scatter(PhpPresentation $objPHPPresentation)
{
    global $oFill;
    global $oShadow;
    // Create templated slide
    echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
    $currentSlide = createTemplatedSlide($objPHPPresentation);
    // local function
    // Generate sample data for fourth chart
    echo date('H:i:s') . ' Generate sample data for chart' . EOL;
    $seriesData = array('Monday' => 0.1, 'Tuesday' => 0.33333, 'Wednesday' => 0.4444, 'Thursday' => 0.5, 'Friday' => 0.4666, 'Saturday' => 0.3666, 'Sunday' => 0.1666);
    // Create a scatter chart (that should be inserted in a shape)
    echo date('H:i:s') . ' Create a scatter chart (that should be inserted in a chart shape)' . EOL;
    $lineChart = new Scatter();
    $series = new Series('Downloads', $seriesData);
    $series->setShowSeriesName(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 Download Distribution')->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);
}
 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);
     $oXMLDoc = TestHelperDOCX::getDocument($this->oPresentation, 'PowerPoint2007');
     $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/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 testTypeScatterSeriesOutline()
 {
     $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);
     $oScatter = new Scatter();
     $oSeries = new Series('Downloads', array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2));
     $oScatter->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oScatter);
     $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);
     $oScatter->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'));
 }