Zoom In by script

Hello,

It is possible to zoom in a chart by script?
I found the function: chart1.control.zoom() but I don’t understand how this works.

Thank you!

Hi Costin,

The function looks like this:

chart1.control.zoom(xStartValue, xEndValue, yStartValue, yEndValue, isAnimated)

Just make sure that the data type you are using for these start and end values is the same as the data type in your chart.

For example if you want to zoom into a chart with dates on the x-axis from 2017 to 2019, with animation, but you don’t care about zooming the y-axis. You would do something like this:

chart1.control.zoom(new Date(‘01/01/2017’),new Date(‘01/01/2019’), null, null, true);

function docs:
https://www.dundas.com/support/api-docs/js/#API%20Reference/dundas/controls/Chart/Methods/zoom.html?Highlight=zoom

1 Like

Thank you @jeff!
Yes, you’re right! I want to zoom in a chart only for x axis which is a date.
My date column looks like this: “12/4/2019 12:00:00 AM”
I’ve tried but I think I did something wrong:

Hi Costin,

I tested this with both a Full DateTime Hierarchy and a Date coming directly out of SQL, in both cases the code works. The only time i saw the code fail was when i gave it an incorrect date (2018 for data between 2010 and 2016), which i expect.

Are you sure your code is being run? maybe it’s placed in an event that isn’t firing?

If you’re still having trouble, it might be a good idea to reach out to the Dundas support team and they’ll be able to help with a deeper investigation.