Pergunta

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.

Foi útil?

Solução

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
        }
    }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top