未检测到 echarts 4.3.0 datazoom 事件

echarts 4.3.0 datazoom event not detected

在启用漫游的情况下,对于具有系列类型图表的图表,我无法检测到数据缩放事件。这是针对 eCharts 4.3.0 的,但我将测试以前的版本以查看它是否是回归。

传入的选项:

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
        }
      }
    }
  ]
};



我都试过了:

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

和:

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

我还测试了添加 datazoom 工具箱组件,也没有检测到缩放事件。

显然图表系列类型不支持 dataZoomAs an alternative,您可以为 graphRoam 附加一个侦听器。

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

这不会提供有关开始和结束缩放状态的信息,但会告诉您缩放是否发生,以及缩放是放大还是缩小。