withr withr - 6 months ago 133
Javascript Question

Highcharts chart.events.redraw doesn't work for chart.xAxis[0].update

I need to change the xaxis step when the chart was redrawed, e.g. when it was zoomed in. I tried the javascript function for like this:

chart: {
zoomType: 'xy',
events: {
redraw: function(){
var chart = $("#container").highcharts();
chart.xAxis[0].update({
lables: {
step: 2
}
})
}
}
}


But, it doesn't work. Is that a buy? Any help will be appreciated!

Answer

It's not possible because will create infinite loop - update options and redraw them in redraw callback. Instead I advice to use afterSetExtremes and call update without redraw: .update( options, false)