我正在尝试格式化 y 轴上的标签
$axis->setFormatCode('#.0\%');
getFormatCode();
这没有提供任何更改,但我已通过在 writer 类中添加 echo 来确认格式代码设置正确。
我已经测试过,如果您更改 Writer\PowerPoint2007\PptCharts.php https://github.com/PHPOffice/PHPPresentation/blob/develop/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php#L2265,这将按预期工作
$objWriter->writeAttribute('sourceLinked', '0');
谁能告诉我为什么会这样,更重要的是如何让 Y 轴用 '%' 格式化值标签?
编辑:添加代码
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);
}
}