简体   繁体   中英

Highstock change xAxis minRange after chart is loaded

I am truing to change the minRange on xAxis after chart has been loaded. i have tried these with no success :

chart.xAxis[0].minRange
chart.xAxis.minRange
chart.xAxis[0].options.minRange
chart.xAxis.options.minRange

none of them works.bu setting the minTickInterval like this works :

chart.xAxis[0].options.minTickInterval

so how can i change minRange at runtime?

UPDATE:I should have mentioned that my axis is type of datetime

UPDATE 2: ok i found the problem, i have this in my code :

    $.each(Analyzer.chart.series, function (index, item) {
        item.setData([]);
    });

to clear the series data, so i can load new data. if i comment this peace of code setting minRange works.

so ??? how to clear series data so that i can change minRange too ????

UPDATE 3: ok i moved the cod in update2 to before setting minRange .... and walla it works :D

for future references : you should set minRange after you have cleared the series data otherwise it wont works.

Try to set the isDirty flag of the xAxis object, and then run the redraw method:

    chart.xAxis[0].minRange = 20;
    chart.xAxis[0].isDirty = true;
    chart.redraw();

Example: http://jsfiddle.net/d2Zdh/

Edit: It should also work when your x axis is of type "datetime". See updated example: http://jsfiddle.net/NnW5G/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM