cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Bar Chart Label Order

Jack_Machesky
9 - Travel Pro
9 - Travel Pro

I was wondering if anyone has a solution to re ordering the labels of a bar chart widget to a custom order. It seems the bars are labeled in alphabetical order, and I would like to change the order of them around. Let me know if you have any ideas, thanks.

1 ACCEPTED SOLUTION

Liliia_DevX
Sisense Team Member
Sisense Team Member

@Jack_Machesky hi! Please review this custom plugin that might help to achieve your goal: Custom Bar/Column Chart Plugin (Show Totals, Sort Categories, Sort Breakbys)

Important note: the provided solution is not an official feature and is not supported or goes through the proper product life cycle. This will require maintenance and proper testing on your side and I also highly recommend running on a staging environment before upgrading or implementing it on production environments.

Best, Lily

View solution in original post

2 REPLIES 2

Liliia_DevX
Sisense Team Member
Sisense Team Member

@Jack_Machesky hi! Please review this custom plugin that might help to achieve your goal: Custom Bar/Column Chart Plugin (Show Totals, Sort Categories, Sort Breakbys)

Important note: the provided solution is not an official feature and is not supported or goes through the proper product life cycle. This will require maintenance and proper testing on your side and I also highly recommend running on a staging environment before upgrading or implementing it on production environments.

Best, Lily

zach_myt
10 - ETL
10 - ETL

On a stacked bar chart you can use the below script to define the order

const breakby = ['category_name1', 'category_name2', 'category_name3'];
widget.on('processresult', function(se, ev) {
ev.result.series.sort(function(a, b) {
if (breakby.indexOf(a.name) < breakby.indexOf(b.name)) {
return -1;
} else if (breakby.indexOf(a.name) > breakby.indexOf(b.name)) {
return 1;
}
return 0;
});

ev.result.legend.reversed = false;
});