【发布时间】:2023-04-09 09:27:01
【问题描述】:
我正在尝试格式化 y 轴上的标签
$axis->setFormatCode('#.0\%');
这没有提供任何更改,但我已通过在编写器类中添加 getFormatCode(); 的回显来确认格式代码设置正确。
我已经测试过,如果您更改 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);
}
}
【问题讨论】:
标签: php phpoffice phppresentation