amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
353 stars 95 forks source link

ValueAxis pan: 'zoom' with live data #1682

Closed OstapchelaEst closed 1 month ago

OstapchelaEst commented 2 months ago

I am trying to use the functionality that changes the scale of the chart on the Y axis when the mouse is clicked and dragged on the Y axis. For static graphs it works fine, but in graphs with dynamic data after the change is not saved and the scale returns to the previous state.

https://jsfiddle.net/v4hc23kg/

martynasma commented 2 months ago

Try setting autoZoom: false on your Y axis:

var valueAxis = mainPanel.yAxes.push(
  am5xy.ValueAxis.new(root, {
    renderer: am5xy.AxisRendererY.new(root, {
      pan: "zoom"
    }),
    autoZoom: false,
    extraMin: 0.1, // adds some space for for main series
    tooltip: am5.Tooltip.new(root, {}),
    numberFormat: "#,###.00",
    extraTooltipPrecision: 2
  })
);