I am trying to format the labels on the y axis
$axis->setFormatCode('#.0\%');
This is providing no change but I have confirmed that the format code is setting properly by adding an echo of getFormatCode();
in the writer class.
I have tested and this will work as expected if you change Writer\PowerPoint2007\PptCharts.php https://github.com/PHPOffice/PHPPresentation/blob/develop/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php#L2265
$objWriter->writeAttribute('sourceLinked', '0');
Can anyone tell me why that is and more importantly how do I get the Y axis to format value labels with '%'?
edit: adding code
public function configure_axis($axis, $title='', $visible=true,
$formatCode=null){
$axis = strtolower($axis);
// get the axis
switch($axis){
case 'x':
case 'categorical':
$axis = $this->shape->getPlotArea()->getAxisX();
break;
case 'y':
$axis = $this->shape->getPlotArea()->getAxisY();
break;
default:
throw new Exception('Invalid axis');
}
$axis->setTitle($title);
$axis->setIsVisible($visible);
if(isset($formatCode)){
$axis->setFormatCode($formatCode);
}
}
Could you show your code and tell which version of PhpPresentation you are using?
Because for me the next formatting
setFormatCode('#.0\%')
is works fine.Here is an example:
And result:
And here's the second result for the column chart (PhpOffice\PhpPresentation\Shape\Chart\Type\Bar):