Ophir_Buchman
05-15-2022Data Integration
Bar Chart - Rename Categories/Break-By
When creating a bar chart you'd sometimes want to rename the categories/break-by fields
Modify the "Break-By" Category Names
Apply the following widget script:
widget.on('processresult', function(widget,result) {
// Translation Dictionary
let dict = {'1':'January', '2':'February', '3':'March', '4':'April', '5':'May', '6':'June', '7':'July', '8':'August', '9':'Septempber', '10':'October', '11':'November', '12':'December'}
result.result.series.forEach(function(ser) {
ser.name = dict[ser.name]
})
})
Before | After |
Modify the "Category" Names
Apply the following widget script:
widget.on('processresult', function(widget,result) {
// Translation Dictionary
let dict = {'1':'January', '2':'February', '3':'March', '4':'April', '5':'May', '6':'June', '7':'July', '8':'August', '9':'Septempber', '10':'October', '11':'November', '12':'December'}
for (let i = 0 ; i < result.result.xAxis.categories.length ; i++) {
result.result.xAxis.categories[i] = dict[result.result.xAxis.categories[i]]
}
})
Before | After |