简体   繁体   English

未检测到 echarts 4.3.0 数据缩放事件

[英]echarts 4.3.0 datazoom event not detected

I'm not able to detect the datazoom event when for a chart with series type graph, with roam enabled.对于具有系列类型图并启用漫游的图表,我无法检测到 datazoom 事件。 This is for eCharts 4.3.0 but I will be testing previous versions to see if it's a regression.这适用于 eCharts 4.3.0,但我将测试以前的版本,看看它是否是回归。

Options passed in:传入的选项:

setup.options = {
  title: {
    top: 'bottom',
    left: 'right'
  },
  animation: false,
  tooltip: {
    trigger: 'item',
    position: 'right',
    confine: true,
    backgroundColor: 'transparent',
    padding: [40, 0, 0, 0],
    enterable: false,
    formatter: function(item) {
      return 'Click for more';
    }
  },
  series : [
    {
      name: '###',
      type: 'graph',
      layout: 'force',
      force: {
        repulsion: 95,
        gravity: 0.015,
        edgeLength: 40,
        layoutAnimation: false
      },
      roam: true,
      draggable: true,
      data: setup.nodes,
      links: setup.links,
      focusNodeAdjacency: true,
      itemStyle: {
        normal: {
          borderColor: '#fff',
          borderWidth: 1,
          shadowBlur: 10,
          shadowColor: 'rgba(0, 0, 0, 0.3)'
        }
      },
      lineStyle: {
        color: 'source',
        curveness: 0.3
      },
      emphasis: {
        lineStyle: {
          width: 10
        }
      }
    }
  ]
};



I have tried both:我都试过了:

// Zoom event listener
(viz.chart).on('datazoom', function(e) {
  console.log('zoomed');
  console.log(e);
});

and:和:

// Zoom event listener
(viz.chart).on('dataZoom', function(e) {
  console.log('zoomed');
  console.log(e);
});

I also tested adding in the datazoom toolbox component, and zoom events were not detected for that either.我还测试了添加数据缩放工具箱组件,也没有检测到缩放事件。

Apparently the graph series type doesn't support dataZoom .显然图形系列类型不支持dataZoom As an alternative , you can attach a listener for graphRoam .作为替代方案,您可以为graphRoam附加一个侦听器。

myChart.on('graphRoam', function(e) {
        console.log('zoom');
});

This won't provide information about the start and end zoom state, but it will tell you whether zooming happened, and whether zoom was in or out.这不会提供有关开始和结束缩放 state 的信息,但它会告诉您是否发生了缩放,以及是否放大或缩小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM