score:5

Accepted answer

because when you use chart.redraw() you should also set isdirty flag as true

http://jsfiddle.net/ukwq9/3/

chart.yaxis[0].isdirty = true;

score:2

update works for me on button 2 as well, chart property can be accessed by closure.

function buttonhandle2(){
    var chart = $('#container').highcharts();
    $("#b2").click(function(){
        chart.yaxis[0].update({
            min:0,
            max: 5,
            tickinterval : 1
        });
    });
}

another option is to set isdirty on axis.

function buttonhandle3(){
    var chart = $('#container').highcharts();
    $("#b3").click(function(){
        chart.yaxis[0].min= 0;
        chart.yaxis[0].max= 5;
        chart.yaxis[0].tickinterval = 1;
        chart.yaxis[0].isdirty = true;
        chart.redraw();
    });
}

code in fiddle. http://jsfiddle.net/mrhunt/ukwq9/5/

better to pass chart as argument to handlers instead of creating separate vars. updated fiddle here: http://jsfiddle.net/mrhunt/ukwq9/6/


Related Query