Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP表示轴标签格式_Php_Phpoffice_Phppresentation - Fatal编程技术网

PHP表示轴标签格式

PHP表示轴标签格式,php,phpoffice,phppresentation,Php,Phpoffice,Phppresentation,我正在尝试格式化y轴上的标签 $axis->setFormatCode('#.0\%') 这没有提供任何更改,但我已通过添加getFormatCode()的回显来确认格式代码设置正确 我已经进行了测试,如果您更改Writer\PowerPoint2007\PptCharts.php,这将按预期工作 $objWriter->writeAttribute('sourceLinked','0') 有人能告诉我为什么会这样吗?更重要的是,我如何让Y轴格式化带有“%”的值标签?能否显示您的代码并告诉我您

我正在尝试格式化y轴上的标签

$axis->setFormatCode('#.0\%')

这没有提供任何更改,但我已通过添加
getFormatCode()的回显来确认格式代码设置正确

我已经进行了测试,如果您更改Writer\PowerPoint2007\PptCharts.php,这将按预期工作

$objWriter->writeAttribute('sourceLinked','0')


有人能告诉我为什么会这样吗?更重要的是,我如何让Y轴格式化带有“%”的值标签?

能否显示您的代码并告诉我您使用的是哪个版本的PhpPresentation

因为对我来说,下一个格式化
setFormatCode('#.0\%')
很好用

以下是一个例子:

<?php

require_once 'vendor/autoload.php';

use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Shape\Chart\Series;
use PhpOffice\PhpPresentation\Shape\Chart\Type\Area;

$seriesData = [
    'Monday' => 12,
    'Tuesday' => 15,
    'Wednesday' => 13,
    'Thursday' => 17,
    'Friday' => 14,
    'Saturday' => 9,
    'Sunday' => 7
];

$objPHPPowerPoint = new PhpPresentation();
$currentSlide = $objPHPPowerPoint->getActiveSlide();
$areaChart = new Area();
$areaChart->addSeries(new Series('Downloads', $seriesData));

$shape = $currentSlide->createChartShape();
$shape->getTitle()->setVisible(false);
$shape->getLegend()->setVisible(false);
$shape->setResizeProportional(false)
    ->setWidth(800)
    ->setHeight(500)
    ->setOffsetX(50)
    ->setOffsetY(50);
$shape->getPlotArea()->setType($areaChart);

$shape->getPlotArea()->getAxisY()->setFormatCode('#.0\%');

$oWriterPPTX = IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
$oWriterPPTX->save(__DIR__ . '/demo.pptx');