cancel
Showing results for 
Search instead for 
Did you mean: 

How to customize the order of a column chart?

kitloong
8 - Cloud Apps
8 - Cloud Apps

2022-01-22_13h55_01.png

I am trying to change the order of the columns. I would like the order be from the left: National, My-Group, Firm 2113, etc. Is it possible?

 

Thanks!

Kit

1 ACCEPTED SOLUTION

harikm007
12 - Data Integration
12 - Data Integration

@kitloong ,

Please try this alternate script to sort items manually

var categories= ['5','4','3','2','1','0'];

widget.on('queryend',function(se,ev){
	ev.rawResult.values.sort(function(a, b){
		var aIndex = categories.indexOf(a[0].data.trim());
		var bIndex = categories.indexOf(b[0].data.trim());

		if (aIndex < bIndex)
			return -1;
		if (aIndex > bIndex)
			return 1;

		return 0;
	})
})

 (update the array 'categories'  with list of items in order)

-Hari

View solution in original post

5 REPLIES 5

harikm007
12 - Data Integration
12 - Data Integration

@kitloong 

If you need to reverse the order of X-axis, try this widget script

widget.on('queryend',function(se,ev){
	ev.rawResult.values.sort(function(a, b){
		var aIndex = a[0].data;
		var bIndex = b[0].data;

		if (a[0].data < b[0].data)
			return 1;
		if (a[0].data > b[0].data)
			return -1;

		return 0;
	})
})

If you need to specify the order manually, please refer this article : 

https://support.sisense.com/kb/en/article/manually-order-a-column-chart

@harikm007 Thanks! I was able to manually order the columns. 

That brings me to another problem. I applied the script to the widget, when I filter a category in the dashboard, that widget doesn't work anymore. I'm wondering if I put that script in the dashboard, will it work? Do you mind pointing me in the correct direction again?

harikm007
12 - Data Integration
12 - Data Integration

@kitloong ,

Please try this alternate script to sort items manually

var categories= ['5','4','3','2','1','0'];

widget.on('queryend',function(se,ev){
	ev.rawResult.values.sort(function(a, b){
		var aIndex = categories.indexOf(a[0].data.trim());
		var bIndex = categories.indexOf(b[0].data.trim());

		if (aIndex < bIndex)
			return -1;
		if (aIndex > bIndex)
			return 1;

		return 0;
	})
})

 (update the array 'categories'  with list of items in order)

-Hari

andyson
Sisense Team Member
Sisense Team Member

Hi Kit,

I usually install this add-on, which lets me perform a custom sort in an easy-to-use UI.

https://support.sisense.com/kb/en/article/custom-barcolumn-chart-plugin-show-totals-sort-categories-...

Hope this helps!

-Andy

Hi Andy,

This looks interesting! However, I believe my company uses the Sisense Cloud, and I don't know how to access it. I'll give it a try when I find out how.

Thanks for your solution.