cancel
Showing results for 
Search instead for 
Did you mean: 

Column Chart - Reorder X-Axis

Ophir_Buchman
12 - Data Integration
12 - Data Integration

When creating a column chart you'd sometimes want to reorder the category fields

Apply the following widget script:

widget.on('processresult', function(widget,result) {
// Wanted Order
let order = ['New','Used','Refurbished','Unspecified']

// For each series
result.result.series.forEach(function(series) {
let newData = new Array(series.data.length);
for (let i = 0 ; i < series.data.length ; i++) {
let categoryName = series.data[i].selectionData[0]
let shouldBeAt = order.indexOf(categoryName)
newData[shouldBeAt] = series.data[i]
}
series.data = newData
})

// Replace X-Axis Labels
result.result.xAxis.categories = order
})
Before After
Ophir_Buchman_0-1652946574383.png Ophir_Buchman_1-1652946592071.png
1 REPLY 1

arivera
7 - Data Storage
7 - Data Storage

I'm trying to do the same for a line chart that uses string values in its X-Axis. Would this work too?