PHPOffice / PHPPresentation

A pure PHP library for reading and writing presentations documents
https://phpoffice.github.io/PHPPresentation
Other
1.31k stars 523 forks source link

A bug occurs when creating a line chart #765

Open 3883688 opened 12 months ago

3883688 commented 12 months ago

When the first element of the inserted array is null, the generated PowerPoint opens blank in office 2016. I set setDisplayBlankAs to Chart::BLANKAS_GAP

$seriesData = [ 'Monday 01' => null, 'Monday 03' => 5, 'Tuesday 02' => 3, 'Wednesday 03' => 1, 'Thursday 04' => 1, 'Friday 05' => 2, 'Saturday 06' => 34, 'Sunday 07' => 1, ]; // 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(false); $series->setShowValue(false);

$series->getMarker()->getBorder()->setColor(new Color('FFFF9045')); $series->getMarker()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFFFC6A0')); $series->getMarker()->setSymbol(Marker::SYMBOL_CIRCLE); $series->getMarker()->setSize(6); $oOutline = new Outline(); // Create a shape (chart) echo date('H:i:s') . ' Create a shape (chart)' . EOL; $shape = $currentSlide->createChartShape(); $shape->setName('')->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80); $shape->setShadow($oShadow); $shape->setFill($oFill); $shape->setDisplayBlankAs(Chart::BLANKAS_GAP); $shape->getBorder()->setLineStyle(Border::LINE_NONE); $shape->getTitle()->setText('PHPPresentation Daily Downloads AAAAAA'); $shape->getTitle()->getFont()->setItalic(true); $shape->getPlotArea()->setType($lineChart); $shape->getView3D()->setRotationX(30); $shape->getView3D()->setPerspective(30); $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_NONE); $shape->getLegend()->getFont()->setItalic(true); $shape->getPlotArea()->getAxisX()->setMajorUnit(1); $shape->getPlotArea()->getAxisY()->setMajorUnit(1);