PHPPowerPoint 从条形图中删除图例

PHPPowerPoint Remove Legend From Bar Graph

我正在使用 PHPPowerPoint 使用 PHP 导出 .ppt 文件。直到现在我想从条形图中删除图例,我都成功了。

生成条形图的代码是:

$chart1 = new Bar();
$series = new Series('City Distribution', $timeseries);
$series->setShowSeriesName(false);
$series->setShowValue(true);
$series->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF1dd2af'));

$chart1->addSeries($series);


$gFill =  new Fill();
$gFill->setFillType(Fill::FILL_GRADIENT_PATH)->setRotation(90)->setStartColor(new Color( 'FF1dd2af' ))->setEndColor(new Color( 'FFFFFFFF' ));

$oFill = new Fill();
$oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFFFFFFF'));

$oShadow = new Shadow();
$oShadow->setVisible(true)->setDirection(45)->setDistance(10);

// Create a shape (chart)
$shape = $currentSlide->createChartShape();
//$shape->getAlignment()->setVertical( Alignment::VERTICAL_TOP );
$shape->getTitle()->setVisible(false);
$shape->setName('City Distribution')->setResizeProportional(false)->setHeight(300)->setWidth(250)->setOffsetX(25)->setOffsetY(200);
$shape->setFill($oFill);
$shape->getTitle()->setText('City Distribution');
$shape->getTitle()->getFont()->setItalic(true);
$shape->getPlotArea()->getAxisX()->setTitle('City');
$shape->getPlotArea()->getAxisY()->setTitle('Number of Users');
$shape->getPlotArea()->setType($chart1);
$shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE);
$shape->getLegend()->getFont()->setItalic(true);

这工作正常,但它正在放置一个我想删除的图例框。有什么想法吗?

没关系我自己想出来了,你只需要:

$shape->getLegend()->setVisible(false);

放在线下

$shape->getTitle()->setVisible(false);