javascriptapexcharts

How to get the min/max xaxis values after user zooms in on apexcharts linechart?


I am trying to get the min/max xaxis values after zooming in on a linechart in apexcharts. Is there a specific method for this?

I have been scouring the documentation and haven't found anything. Can somebody please help?


Solution

  • If you check the docs, there is an event for zoom. There are 2 other events that deal with zooming: beforeZoom and beforeResetZoom.

    You get the state of both the xaxis and yaxis in the event callback.

    zoomed: function

    Fires when user zooms in/out the chart using either the selection zooming tool or zoom in/out buttons. The 2nd argument includes information of the new xaxis/yaxis generated after zooming.

    chart: {
      events: {
        zoomed: function(chartContext, { xaxis, yaxis }) {
          // ...
        }
      }
    }