Forum Discussion

amelia's avatar
04-01-2022
Solved

Month Name in Order for Column Chart

Hi Sisense Community - I would like to change the numbers in the column chart to the month names (e.g 1 should be 'January', 2 should be 'February', and so on...) 

The examples I found online only manage to change the labels in the x-axis from numbers to the month names, would anyone know what script I should use to change the labels in the column chart below?

  • amelia ,

    Please try below script. Update the variable newItemMapping  with number and month name

    
    newItemMapping = { '1':'Jan',
    				  '2':'Feb',
    				  '3':'Mar'
    				}
    
    widget.on("queryend", function(se, ev){
    		
    	$.each(ev.rawResult.values, function(index, value){
    		if(newItemMapping[value[0].text] != undefined)
    		{
    			value[0].data = newItemMapping[value[0].data]
    			value[0].text = newItemMapping[value[0].text]
    		}
    	})
    		
    })
    

     

    -Hari

     

6 Replies

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

    amelia ,

    Please try below script. Update the variable newItemMapping  with number and month name

    
    newItemMapping = { '1':'Jan',
    				  '2':'Feb',
    				  '3':'Mar'
    				}
    
    widget.on("queryend", function(se, ev){
    		
    	$.each(ev.rawResult.values, function(index, value){
    		if(newItemMapping[value[0].text] != undefined)
    		{
    			value[0].data = newItemMapping[value[0].data]
    			value[0].text = newItemMapping[value[0].text]
    		}
    	})
    		
    })
    

     

    -Hari

     

  •  Hi Hari, I tried this out but it didn't work. I think it's because the month column I want to change doesn't lie on the x-axis 🤔 

    • harikm007's avatar
      harikm007
      Data Warehouse

      Can you share a screenshot of right-side panel where you added Categories and Measures?

      -Hari

      • amelia's avatar
        amelia
        ETL

        Sure, here it is