cancel
Showing results for 
Search instead for 
Did you mean: 

Month Name in Order for Column Chart

amelia
9 - Travel Pro
9 - Travel Pro

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?

1 ACCEPTED SOLUTION

harikm007
12 - Data Integration
12 - Data Integration

@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

 

View solution in original post

6 REPLIES 6

harikm007
12 - Data Integration
12 - Data Integration

@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

 

amelia
9 - Travel Pro
9 - Travel Pro

 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
12 - Data Integration
12 - Data Integration

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

-Hari

Sure, here it is 

harikm007
12 - Data Integration
12 - Data Integration

Interesting, I tried using similar fields and it worked. Is there any other scripts in your widget? I'm trying to reproduce the issue.

harikm007_0-1648838943134.png

 

-Hari

Perfect, I managed to do it - i realised I had defined newItemMapping as a constant, but it worked when I removed that. Thank you 🙂