gpt4 book ai didi

charts - PHPExcel 饼图标签和图例

转载 作者:行者123 更新时间:2023-12-04 17:37:57 24 4
gpt4 key购买 nike

我的库 PHPExcel (1.7.7) 有问题:当我想创建饼图时,不显示标签和图例。但是,对于其他图形,我没有这个问题。你有什么解决办法吗?

谢谢。

这是使用的代码:

$categories = array(
new PHPExcel_Chart_DataSeriesValues('String', 'RECAPITULATIF!$B$6:$B$8', null, 3),
);

$values = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'RECAPITULATIF!$F$6:$F$8', null, 3),
);

$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_PIECHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
array(0), // plotOrder
null, // plotLabel
$categories, // plotCategory
$values // plotValues
);

$plotarea = new PHPExcel_Chart_PlotArea(null, array($series));
$title = new PHPExcel_Chart_Title('Pie chart');
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, null, false);

$chart = new PHPExcel_Chart(
'chart2', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
null, // xAxisLabel
null // yAxisLabel
);

最佳答案

我们必须通过声明 setShowVal(TRUE) 来启用数据标签。

找到我应用的以下代码

$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
array(0, 1), // plotOrder
$labels, // plotLabel
$categories, // plotCategory
$values // plotValues
);

$layout1 = new PHPExcel_Chart_Layout();
$layout1->setShowVal(TRUE); // Initializing the data labels with Values
$layout1->setShowPercent(TRUE); // Initializing the data labels with Percentages

申请的地块面积需要申报
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
$plotarea = new PHPExcel_Chart_PlotArea($layout1, array($series));
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, null, false);
$chart = new PHPExcel_Chart(
'chart1', // name
null, // title
$legend, // legend
$plotarea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
null, // xAxisLabel
null // yAxisLabel
);

关于charts - PHPExcel 饼图标签和图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12263366/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com