最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Apex charts disable scrollingzooming - Stack Overflow

programmeradmin3浏览0评论

I have built a chart using the ApexCharts library and I want to disable the possibility of dragging the chart. How should I update my configurations (see below)? I couldn't find any detail in the documentation. This is my chart:

//My ponent
<Chart
  options={performanceLineChart.options}
  series={performanceLineChart.series}
/>

//My configurations
export const performanceLineChart = {
  options: {
    chart: {
      id: 'my-chart',
      type: 'line' as 'line',
      toolbar: {
        show: false //Disable toolbar
      }
    },
    stroke: {
      width: 5,
      curve: 'smooth' as 'smooth'
    },
    markers: {
      size: 4,
      hover: {
        size: undefined,
        sizeOffset: 2
      }
    },
    xasis: {
      type: 'numeric',
    }
  },
  series: [{
    name: 'Line 1',
    data: [
      [3066, 323],
      [6317, 312],
      [12498, 313],
      [24091, 326]
    ]
  },{
    name: 'Line 2',
    data: [
      [3516, 281],
      [7378, 268],
      [11502, 344],
      [21219, 371]
    ]
  }]
}

I have built a chart using the ApexCharts library and I want to disable the possibility of dragging the chart. How should I update my configurations (see below)? I couldn't find any detail in the documentation. This is my chart:

//My ponent
<Chart
  options={performanceLineChart.options}
  series={performanceLineChart.series}
/>

//My configurations
export const performanceLineChart = {
  options: {
    chart: {
      id: 'my-chart',
      type: 'line' as 'line',
      toolbar: {
        show: false //Disable toolbar
      }
    },
    stroke: {
      width: 5,
      curve: 'smooth' as 'smooth'
    },
    markers: {
      size: 4,
      hover: {
        size: undefined,
        sizeOffset: 2
      }
    },
    xasis: {
      type: 'numeric',
    }
  },
  series: [{
    name: 'Line 1',
    data: [
      [3066, 323],
      [6317, 312],
      [12498, 313],
      [24091, 326]
    ]
  },{
    name: 'Line 2',
    data: [
      [3516, 281],
      [7378, 268],
      [11502, 344],
      [21219, 371]
    ]
  }]
}
Share Improve this question edited Nov 25, 2021 at 12:39 Andrea Costanzo asked Nov 24, 2021 at 13:15 Andrea CostanzoAndrea Costanzo 2,2254 gold badges17 silver badges40 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 12

I'm guessing you're talking about selection zoom, you can turn it off like this

chart: {
  id: 'my-chart',
  type: 'line' as 'line',
  toolbar: {
    show: false
  },
  zoom: {
    enabled: false,
  }
},

Not sure if these issue still persist. For future, ApexCharts v3.54.1. Do set allowMouseWheelZoom: false.

chart: {
  id: 'my-chart',
  type: 'line' as 'line',
  toolbar: {
     show: false
  },
  zoom: {
     enabled: false,
     allowMouseWheelZoom: false,
  }
}
发布评论

评论列表(0)

  1. 暂无评论