PHPPowerPoint从条形图中删除图例

时间:2016-01-27 20:11:47

标签: php phpexcel phppowerpoint

我正在使用PHPPowerPoint使用.ppt导出PHP文件。直到现在我才想要从条形图中删除图例。

生成条形图的代码是:

$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);

这工作得很好,但它正在放置一个传说框,我想删除它。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

没关系我自己想出来了,你需要做的就是:

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

将它放在

行下面
$shape->getTitle()->setVisible(false);