charts - PhpSpreadSheet 图表 TYPE_BARCHART_3D 自定义颜色
问题描述
我寻求帮助以便能够自定义 PhpSpreadSheet 图表,最好是导出到 excel 时的条形类型,以便它以圆柱形状出现并且可以独立定义每个条形的颜色
这是我的代码
// Custom colors for dataSeries (gray, blue, red, orange...........)
$colors = [
'00a3f5', '00a3f5', '00a3f5', '00a3f5', '00a3f5', '00a3f5', '00a3f5', '00a3f5', '00a3f5', '00a3f5', '00a3f5',
];
$dataSeriesLabels1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // 2010
];
$xAxisTickValues1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A12', null, 11), // PI to ANI
];
$dataSeriesValues1 = [
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2', null, 11, [], null, $colors),
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$3:$B$12', null, 11, [], null, $colors),
];
$series1 = new DataSeries(
DataSeries::TYPE_BARCHART_3D, // plotType
null, // plotGrouping (Pie charts don't have any grouping)
range(0, count($dataSeriesValues1) - 1), // plotOrder
$dataSeriesLabels1, // plotLabel
$xAxisTickValues1, // plotCategory
$dataSeriesValues1 // plotValues
);
$layout1 = new Layout();
$layout1->setShowVal(true);
$layout1->setShowPercent(true);
$legend1 = new Legend(Legend::POSITION_RIGHT, null, false);
$title1 = new Title('My Bar');
$chart1 = new Chart(
'chart1', // name
$title1, // title
$legend1, // legend
$plotArea1,
true,
DataSeries::EMPTY_AS_GAP,
null,
null
);
解决方案
并非所有图表类型都已实现。也许这是不支持的之一。
推荐阅读
- hyperledger-fabric - 在 Hyperledger Fabric 2.2 中设置 logspout 时出现错误
- konvajs - 在 konvajs 中将某个对象拖放到它们上后,是否可以旋转一个组?
- asp.net - VB6代码获取调用aspx路径信息
- python - Flask SQLAlchemy中的查询结果不一致
- javascript - 从转换后的 HTML 画布中获取图像数据
- python - 如何在条目小部件的 tkinter 显示中清除 Intvar() 的默认值为 0?
- java - 即使应用程序在后台,如何发出通知?
- python - 如何拉出嵌套文档
- adfs3.0 - ADFS 自定义声明返回过滤的组成员身份?
- python - 使用 smtp 发送电子邮件(需要帮助)