【发布时间】:2019-04-08 13:52:20
【问题描述】:
是否可以覆盖旭日形图的全局图表颜色?我尝试了多种方法,但似乎都没有奏效。
请检查这个小提琴:https://jsfiddle.net/max1tdzh/
chart: {
height: '100%',
colors: ['#ff0000', '#00ff00', '#0000ff']
},
plotOptions: {
series: {
colors: ['#ff0000', '#00ff00', '#0000ff']
},
sunburst: {
colors: ['#ff0000', '#00ff00', '#0000ff']
}
},
我尝试过设置 chart.colors、plotOptions.sunburst.colors 和 plotOptions.series.colors,但似乎都不起作用。
有效的是在 series.data 数组中的特定数据点上设置颜色属性,但这个解决方案并不好,因为它需要使用这样的自定义辅助函数循环所有元素:
let colorIndex = 0;
return data.map((point) => {
if (!point.parent) {
const color = colors[colorIndex % colors.length];
colorIndex++;
return { ...point, color };
}
return point;
});
【问题讨论】:
标签: javascript highcharts sunburst-diagram