Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable scroll wheel zoom in ApexCharts?

I've got a line chart in my app using ApexCharts:

import ApexCharts from "apexcharts";

var options = {
  chart: {
    type: "line",
  },
  series: [
    {
      name: "sales",
      data: [30, 40, 35, 50, 49, 60, 70, 91, 125],
    },
  ],
  xaxis: {
    categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999],
  },
};

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();

When I hover the chart and scroll using the mouse wheel, the chart zooms in/out. How do I disable this behavior while still allowing to select areas of the chart to Zoom (just disable the scroll wheel behavior)?

Example

like image 487
gespinha Avatar asked Oct 20 '25 02:10

gespinha


1 Answers

To disable the zoom when using the mouse wheel, you can use the property chart.zoom.allowMouseWheelZoom

For example, the code below disables the zoom for scrolling only (The area can still be zoomed in on by selecting it):

chart = {
  type: "area",
  zoom: {
    enabled: true,
    allowMouseWheelZoom: false
  }
}
like image 69
xPiL0Tx Avatar answered Oct 21 '25 16:10

xPiL0Tx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!