PHPPresentation
PHPPresentation copied to clipboard
How to display a series value as percentages instead of numbers?
I am trying to display the Y units are percentages (10%,20%..100%) but it displays them as values (0.1, 0.2,...,1.0)
Here is the code
`
$seriesAoC = array(
'01/07/2015' => 0.2,
'01/08/2015' => 0.5,
'01/09/2015' => 0.8,
'01/10/2015' => 1.0
); //supposed to display plots at 20%, 50%, 80% and 100% on axis Y ???
$oFill = new Fill();
$oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFFFFFFF'));
$lineChart = new Line();
$series = new Series('AoC', $seriesAoC);
$series->setShowSeriesName(false);
$series->setShowValue(false);
$series->setShowPercentage(true); //series axis label should be in percentage not decimals
$series->setShowLeaderLines(false);
$lineChart->addSeries($series);
$oGridLines = new Gridlines();
$oGridLines->getOutline()->setWidth(1);
$oGridLines->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFD9D9D9'));
$shape = $slide->createChartShape();
$shape->setName('Completion Percentage')->setResizeProportional(false)->setHeight(300)->setWidth(550)->setOffsetX(50)->setOffsetY(120);
$shape->getPlotArea()->getAxisY()->setMajorGridlines($oGridLines);
$shape->getPlotArea()->getAxisY()->setMajorUnit(0.1);
$shape->getPlotArea()->getAxisY()->setMaxBounds(1.0);
$shape->getPlotArea()->getAxisY()->setMinBounds(0.0);
$shape->getPlotArea()->getAxisY()->setFormatCode('0%');
$shape->getPlotArea()->getAxisY()->setTitle("");
$shape->getPlotArea()->getAxisX()->setTitle("");
$shape->setFill($oFill);
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE)->setLineWidth(0.5);
$shape->getTitle()->setText('Sample Title');
$shape->getTitle()->getFont()->setSize(10);
$shape->getTitle()->getAlignment()->setIndent(180);
$shape->getPlotArea()->setType($lineChart);
$shape->getView3D()->setRotationX(30);
$shape->getView3D()->setPerspective(30);
$shape->getLegend()->getBorder()->setLineStyle(Border::LINE_NONE);
$shape->getLegend()->setPosition(Legend::POSITION_TOP);
$shape->getLegend()->getFont()->setSize(8);
`
Has anybody faced this issue or know how to display axis units as percentages and not as decimals?