Search code examples
amchartsamcharts4

amCharts 4 - How to Disable Scrollbar to Prevent Zooming and Panning


See this pen. How can I disable the scrollbar to prevent zooming and panning without changing the position of the top of the chart?

The following code will remove the scrollbar completely (causing the top of the chart to move upward):

chart.scrollbarX.disabled = true;

The following code disables zooming but still allows panning:

chart.scrollbarX.startGrip.disabled = true;
chart.scrollbarX.endGrip.disabled = true;

Any suggestions would be appreciated.


Solution

  • You can set interactionsEnabled to false on the scrollbar object to prevent any mouse/touch interactions from modifying it.

    scrollbarX.interactionsEnabled = false;
    

    Updated codepen