PDA

View Full Version : Dynamically Change Chart Axis Title



jkraft04
4 Oct 2011, 7:55 AM
How do I dynamically change a chart's axis title? I would like to change the title on the bottom axis of a column chart. I would like to do this when a user clicks on a column in the chart. I have a listener set up but what code do I put in there to update the title?



axes: [{
type: 'Numeric',
position: 'left',
fields: ['total'],
title: false,
grid: true
}, {
type: 'Category',
position: 'bottom',
fields: ['title'],
title: 'Title to be Changed Dynamically'
}],
series: [{
type: 'column',
axis: 'left',
listeners: {
itemmousedown: function(o){
//what goes here to update title of bottom axis?
}
}]

jkraft04
5 Oct 2011, 6:49 AM
Does anyone have at least an idea of what might work?

jc5
7 Oct 2011, 12:47 PM
How about something like


var ba = item.series.chart.axes.get('bottom');
ba.setTitle('my title');


Regards,
Jamie

jkraft04
7 Oct 2011, 12:58 PM
Thank you. I tried that but it didn't work. I was able to modify it so it works. Here is what I came up with:



var ba = this.chart.axes.get('bottom');
ba.setTitle('new title');