cancel
Showing results for 
Search instead for 
Did you mean: 

Bar Chart - Rename Categories/Break-By

Ophir_Buchman
12 - Data Integration
12 - Data Integration

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
Ophir_Buchman_0-1652640891727.png Ophir_Buchman_1-1652640905222.png

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
Ophir_Buchman_2-1652640949007.png Ophir_Buchman_3-1652640966095.png
1 REPLY 1

qizhang
7 - Data Storage
7 - Data Storage

what if there is two categories? can we rename them?