user736893
user736893

Reputation:

set color from datasource like you would set argumentField or valueField?

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.

Upvotes: 0

Views: 794

Answers (1)

petru negrei
petru negrei

Reputation: 26

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
        }
    }
}

Upvotes: 1

Related Questions