cancel
Showing results for 
Search instead for 
Did you mean: 

Sort Funnel Chart Category Order

gwolfe
10 - ETL
10 - ETL

Hi, does anyone have a script to custom sort the order of categories on a Funnel Chart? Thanks. 

1 ACCEPTED SOLUTION

harikm007
13 - Data Warehouse
13 - Data Warehouse

@gwolfe 

Please try this script:

var categories= ['Jan','Feb','Mar','Apr','May','Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
widget.on('queryend',function(se,ev){
	ev.rawResult.values.sort(function(a, b){
		var aIndex = categories.indexOf(a[0].data);
		var bIndex = categories.indexOf(b[0].data);
						
		if (aIndex < bIndex)
			return -1;
		if (aIndex > bIndex)
			return 1;
							
		return 0;
	})
})

Reference : https://www.binextlevel.com/post/sort-bar-columns-breakby-manually

-Hari

View solution in original post

2 REPLIES 2

harikm007
13 - Data Warehouse
13 - Data Warehouse

@gwolfe 

Please try this script:

var categories= ['Jan','Feb','Mar','Apr','May','Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
widget.on('queryend',function(se,ev){
	ev.rawResult.values.sort(function(a, b){
		var aIndex = categories.indexOf(a[0].data);
		var bIndex = categories.indexOf(b[0].data);
						
		if (aIndex < bIndex)
			return -1;
		if (aIndex > bIndex)
			return 1;
							
		return 0;
	})
})

Reference : https://www.binextlevel.com/post/sort-bar-columns-breakby-manually

-Hari

Thank you. That worked perfectly.