鉴于以下数据,我可以利用“颜色”字段设置系列颜色吗?
{ severity: "minor", count: 30, color: 'yellow' },
{ severity: "major", count: 23, color: 'orange' },
{ severity: "critical", count: 12, color: 'red' },
{ severity: "resolved", count: 35, color: 'green' }
这是图表定义。我可以使用argumentField指定severity和valueField来指定count,但是没有这样的颜色参数:
dxPieChart: {
dataSource: dsAlarmsBySeverity,
size: {
width: 275,
height: 150
},
series: [{
type: 'doughnut',
argumentField: 'severity',
valueField: 'count',
label: {
visible: false
}
}]
}
颜色只需要基于严重程度,所以我会接受任何能够实现这一目标的答案。
答案 0 :(得分:1)
解决方案如下,您需要添加带有指示返回的customize_point
字段:
dxPieChart: {
dataSource: dsAlarmsBySeverity,
...,
customizePoint: function (point) {
return {
color: dsAlarmsBySeverity[point.index].color
}
}
}