Zoom out on a chart by scripting

One thing that, in my case, I found very useful and decreases the number of mouse clicks is to zoom out on a chart axis using scripting. You can put it on a image click event and zoom out without need for the context menu. It’s a line of code: chart1.control.undoZoom(). Follows an example:

image

Explanation: On the bottom right corner of the chart I placed a magnifying glass image, that when you click it and you have made a zoom in on the chart, it zooms out without the need of the popup menu. Hope it’s helpful, for me it was!

4 Likes

Just to note, that this will only zoom out one level. So if you have zoomed in multiple times, it will not return to the totally unzoomed view unless you click it multiple times.

I do not know if there is a way to undo all the zooming in one click.

I did an ugly button zoom out zoom in. My users do not explore the right click options on charts so I have to make available anything they want to do by right clicking via a scripted click event.

My script hides the zoom out button when it is click and show the zoom in button. This way they can easily zoom in and out one between two levels.

I have no idea why I did not think of using and Image of the magnifying glass, one with minus one with plus. That would look so much better than a button with text “Zoom IN”.

Yes, it’s true David you have to click several times to reset the zoom. I also don’t know if it’s possible to undo all the zooming in one click, but if possible it would be even better! :slight_smile:

Hello @luis.silva,

I had the same issue in the past but the support team helped me.

On the data change of the chart I put this script:
if (chart6.control.xViewport.endValue!= null && chart6.control.xViewport.startValue !=null)
{button13.hidden = false; }

And for the zoom out button the script is:
chart6.control.xViewport.maxVisibleCategories=0;
chart6.loadData();
button13.hidden = true;

I hope this will work for you too!

1 Like

Hello @costin.manea,

Thanks a lot for your post on this issue, it works for me also!

Regards

2 Likes