'Using amCharts5 is there a way to snap the dateAxis visible min and max to the nearest data item \ baseInterval \ groupInterval?

I'm trying to find a way to snap the xAxis in a line chart to the closest min and max data points in the visible chart area.

As you can see in any of the line chart demos, when zooming or panning the chart, the start and end position of the chart will not snap to the nearest data item (i.e. day, or month when grouped etc.). After zooming or panning the chart, the start\end of the chart area will be at some point based on where you zoomed or panned, but very difficult to land it exactly on the interval.

I'd really like to figure out a way to snap the min and max position of the visible chart area to the nearest min and max data points, ideally using short but smooth animation to snap once the zoom\pan event is finished\released.

I figure this is possible somehow by using something like the DateAxis zoomToDates method after a zoom\pan event is triggered, but haven't been able to find a way to do it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source