Forum Discussion

amelia's avatar
03-30-2022
Solved

Order Months in Column chart by logical order

Hi Sisense community, I would like to order the months in my column chart according to the logical order, but right now it's mainly showing alphabetical order. Would anyone be able to assist on this?...
  • harikm007's avatar
    03-30-2022

    amelia ,

    Try this script - https://www.binextlevel.com/post/sort-bar-columns-breakby-manually

    Here, update the list 'breakby' with list of months in order

    breakby = ['West', 'Midwest', 'South', 'Northeast', 'Unknown']
    widget.on('processresult',function(se,ev){
    	ev.result.series.sort(function(a,b){
    		if (breakby.indexOf(a.name) < breakby.indexOf(b.name)) {
    			return -1
    		}
    		else if (breakby.indexOf(a.name)>breakby.indexOf(b.name)) {
    			return 1
    		}
    		return 0;
    	});
    })

    -Hari