How to programmatically zoom in highcharts?

*爱你&永不变心* 提交于 2020-01-02 17:36:13

问题


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:


You can also call setState on the button.

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

chart.rangeSelector.buttons[3].setState(2);


来源:https://stackoverflow.com/questions/23397598/how-to-programmatically-zoom-in-highcharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!