Highcharts Reset Zoom 'after calling setExtremes

I use setExtremes to enlarge the details in the diagram, and also so that the user can enlarge "x, y" by selecting in the diagram. When the user zooms in, they get a "reset zoom" button, however, when I call setExtremes, I do not.

Is there a way to make the 'reset increase' button programmatically?

UPDATE:

call

if( !chart.resetZoomButton ) { chart.showResetZoom(); } 

a button appears inside the afterSetExtremes event handler, but clicking it does nothing.

UPDATE:

Instead of calling setExtremes, I changed the call

chart.xaxis [0] .zoom (minx, maxx); chart.yaxis [0] .zoom (miny, maxy); chart.redraw ();

This has the same effect as a custom scale by selecting in a chart.

+6
source share
4 answers

Just looked at the HighCharts source code, it looks like this might work for you:

 chart.showResetZoom(); 

In addition, for the button to work correctly, you must use axis.zoom instead of setting extreme values:

 axis.zoom(newMin,newMax); 

Let me know if this works!

+10
source

You can use showResetZoom , but you need to check that the reset button is already visible, otherwise it will not disappear .

 if( !chart.resetZoomButton ) { chart.showResetZoom(); } 
+4
source

This approach works well:

 if (!$('.highcharts-button').length) { chart.showResetZoom(); } 

It is assumed that the only button that can be displayed is the Reset Zoom button. If it already exists, do not show another.

If you do not do this check, a new button is added each time showResetZoom() called. Pressing the visible (most recent) button resets the button and removes the button, but the old buttons are still visible and do nothing.

0
source

If you use setExtremes, you can also set min and max to null before reset:

 chart.xAxis[0].setExtremes(null, null) 
0
source

All Articles