0

我在设置图例标签的宽度时遇到问题。我可以展示它们,但无法按预期展示它们。

目前它看起来像这样

我希望 Legend 像这样显示

我的代码

//NOTE Layer for charts
$layout=new \PHPExcel_Chart_Layout();
$layout->setShowVal(true);
$layout->setShowPercent(true);
// Set series in the plot area
$pa=new \PHPExcel_Chart_PlotArea($layout, array($ds));
// Set legend
$legend=new \PHPExcel_Chart_Legend(\PHPExcel_Chart_Legend::POSITION_BOTTOM, NULL, false);
//Create Chart
$chart= new \PHPExcel_Chart('chart1',$title,$legend,$pa,true,0,NULL, NULL);

$chart->setTopLeftPosition('K'.$chart_index);
$chart->setBottomRightPosition('S'.($chart_index+20));
$ews2->addChart($chart);
4

1 回答 1

0

我已经为我的问题找到了解决方案。

我刚刚创建了带有预期标签的数组;

$pie_label = array($ea->getActiveSheet()->getCell("E".$i)->getValue(),$ea->getActiveSheet()->getCell("F".$i)->getValue(),$ea->getActiveSheet()->getCell("G".$i)->getValue(),$ea->getActiveSheet()->getCell("H".$i)->getValue());

并将其附加在 PHPExcel_Chart_DataSeriesValues 函数的末尾,并将函数的第二个参数转换为 null。

$spec_label = array(new \PHPExcel_Chart_DataSeriesValues('String', null, NULL, 1,$pie_label),);
于 2021-01-11T18:17:41.207 回答