How to programmatically zoom in highcharts?

2019-05-23 15:26发布

When calling axis.setExtremes() or axis.zoom(), the associated zoom button does not become highlighted.

For example, if I programatically 'zoom' to 1-hour, I would like the '1 hour' zoom button to appear as 'pressed'.

Is there a simple way to accomplish this?

For more context: I want to make my app stately, so that if you view a graph, zoom, then navigate away from the graph and back to it again, I want to restore your 'zoom level'.

I have this basically working by listening for afterSetExtremes and storing the max/min values, and then using those to call 'zoom' on the graph when the user returns.

If there is a simpler way to accomplish this, I'd be fine with that.

Thanks for any direction!

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-05-23 15:59

You can also call setState on the button.

http://jsfiddle.net/W56P5/2/

chart.rangeSelector.buttons[3].setState(2);
查看更多
登录 后发表回答