Fingelrest
Posts: 11
Joined: Mon Feb 07, 2011 2:40 pm

[Solved] Programmatically reset the zoom?

Hi all,

To plot different things, I re-use the same Highcharts object instead of re-creating one very time. Right now I'm able to do everything except resetting the zoom: If the user has zoomed on a part of the chart, when I'm replacing the series by another one, the zoom stays the same instead of being reseted.

If there a way to do that?
Last edited by Fingelrest on Tue Feb 14, 2012 2:10 pm, edited 1 time in total.
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Programmatically reset the zoom?

You can reset zoom by chart.xAxis[0].setExtremes()
Paweł Fus
Highcharts Developer
Fingelrest
Posts: 11
Joined: Mon Feb 07, 2011 2:40 pm

Re: Programmatically reset the zoom?

Cool thanks! Now the only thing is that the 'Reset zoom' label is still displayed even though it's no longer needed. Is there a way I can remove it as well?
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Programmatically reset the zoom?

By the way, chart.series.setData() doesn't reset the zoom?
Paweł Fus
Highcharts Developer
Fingelrest
Posts: 11
Joined: Mon Feb 07, 2011 2:40 pm

Re: Programmatically reset the zoom?

Just tried setData(), and it doesn't seem so. Currently I'm removing the existing series before adding a new one.
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Programmatically reset the zoom?

You can do this way:

Code: Select all

jQuery("#container svg text:last").remove() //or hide()
but I haven't tested if there are no issues.
Paweł Fus
Highcharts Developer
Fingelrest
Posts: 11
Joined: Mon Feb 07, 2011 2:40 pm

Re: Programmatically reset the zoom?

Fusher wrote:You can do this way:

Code: Select all

jQuery("#container svg text:last").remove() //or hide()
but I haven't tested if there are no issues.
I indeed have issues with the tooltip when using this, it looks like just an empty small circle with nothing inside. Too bad, I guess I'll have to live with the reset zoom link.
scu
Posts: 18
Joined: Mon Jan 23, 2012 2:58 pm

Re: Programmatically reset the zoom?

I did a workaround by editing the highcharts.src.js:

Search for "// Expose methods and variables" and add "chart.zoomOut = zoomOut;"
Now you can trigger the reset with executing "yourChart.zoomOut();"
Fingelrest
Posts: 11
Joined: Mon Feb 07, 2011 2:40 pm

Re: Programmatically reset the zoom?

Cool, thanks a lot! Exactly what I needed.

Return to “Highcharts Usage”