Question

Given the following data, can I utilize the "color" field to set the series color?

{ severity: "minor", count: 30, color: 'yellow' },
{ severity: "major", count: 23, color: 'orange' },
{ severity: "critical", count: 12, color: 'red' },
{ severity: "resolved", count: 35, color: 'green' }

And here is the chart definition. I can use argumentField to specify severity and valueField to specify count, but there is no such parameter for color:

dxPieChart: {
    dataSource: dsAlarmsBySeverity,
    size: {
        width: 275,
        height: 150
    },
    series: [{
        type: 'doughnut',
        argumentField: 'severity',
        valueField: 'count',
        label: {
            visible: false
        }
    }]
}

The color just needs to be based on the severity, so I'll accept any answers that accomplish that.

Was it helpful?

Solution

The solution is as follows, you need to add the customize_point field with indicated return:

dxPieChart: {
    dataSource: dsAlarmsBySeverity,
    ...,
    customizePoint: function (point) {
        return {
            color: dsAlarmsBySeverity[point.index].color
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top