cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort legends in pie chart Manually

rameshp0233
7 - Data Storage
7 - Data Storage

I wanted to sort Legends in Pie Chart  Manually according to  my wish. Any information or code  related to it will appreciated.

 

rameshp0233_0-1647943276732.png

 

1 REPLY 1

harikm007
13 - Data Warehouse
13 - Data Warehouse

@rameshp0233 ,

Please try the script mentioned here

 

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;
	})
})

-Hari