美文网首页
echarts框选+缩放折线图

echarts框选+缩放折线图

作者: 眠九 | 来源:发表于2018-04-13 17:22 被阅读0次

分别用brush和dataZoomSelect组件,做出框选,缩放效果,highcharts上有现成使用的方法,echart需要自己去找,特表是dataZoomSelect,在toolbox上自动开启,就可以直接使用,另外本来打算自己写个d3的方法,但是,d3上关于获取框选数据这一块比较麻烦,只能定位坐标,根据坐标计算框选的数据,计算过程略微复杂。写到一半,放弃了,主要是项目时间紧张,略略略。

1.使用dataZoomSelect

配置项说明

toolbox:{
      feature : {
            dataZoom : {
                      yAxisIndex : "none"   //不启用y轴的选中
            }
      }
}

方法使用dispatchAction

myChart.dispatchAction({
      type : "takeGlobalCursor",
      key : "dataZoom",
      dataZoomSelectActive : true
})

在图形缩放时触发函数

myChart.on("dataZoom",function(param){
        //缩放时触发函数
})

2.使用brush

brush配置

brush: {
       toolbox: ['lineX'],
       xAxisIndex: 'all',
       throttleType: 'debounce',
       throttleDelay: 100,
       outOfBrush: {
               colorAlpha: 1
       },
       inBrush: {
               colorAlpha: .3
       }
}

方法使用dispatchAction

myChart.dispatchAction({
       type: 'takeGlobalCursor',
       key: 'brush',
       brushOption: {
              brushType: 'lineX'
       }
});

相关文章

网友评论

      本文标题:echarts框选+缩放折线图

      本文链接:https://www.haomeiwen.com/subject/vaqhkftx.html