Zack
Zack

Reputation: 301

How to programmatically zoom in highcharts?

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!

Upvotes: 2

Views: 3505

Answers (1)

Sebastian Bochan
Sebastian Bochan

Reputation: 37588

You can also call setState on the button.

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

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

Upvotes: 1

Related Questions