Forum Discussion

Chandra's avatar
Chandra
Cloud Apps
01-27-2022

Issue In Sorting X-axis Labels

Hi Sisense Community..

I am having an issue in arranging the x-axis labels in Heat Map. In this first we have chosen scatter chart and  then converted in to heat map using the below code

widget.on('beforeviewloaded',function(se,ev){
ev.options.chart.type='heatmap'
})

For this we have tried with some scripts in order to sort X-axis values but no change .Can anyone help in this?

 

 

2 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    Chandra ,

    Try this script to sort X-axis (update the array 'categories' with list of X-axis items in order) : 

    var categories= ['South','West','Midwest','Northeast','Unknown'];
    
    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;
    	})
    })

    -Hari