Forum Discussion

kitloong's avatar
kitloong
Cloud Apps
01-22-2022
Solved

How to customize the order of a column chart?

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

  • 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

5 Replies

Replies have been turned off for this discussion
    • kitloong's avatar
      kitloong
      Cloud Apps

      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's avatar
        harikm007
        Data Warehouse

        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

    • kitloong's avatar
      kitloong
      Cloud Apps

      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.