echart折线图点击事件包括任意位置
echarts 点击柱状图触发的事件
// myChart.on('click', function (params) { // let data = { // type:"age", // index:params.dataIndex // } // that.$emit('isShowCurrentDialog',data) // })
折线图使用的话 只有点击这下图拐点的点 才能触发
myChart.getZr().on('click',params=>{ const pointInPixel= [params.offsetX, params.offsetY]; if (myChart.containPixel('grid',pointInPixel)) { let xIndex=myChart.convertFromPixel({seriesIndex:0},[params.offsetX, params.offsetY])[0]; //当前点击的x坐标 // console.log(xIndex) let data = { type:"age", index:xIndex } that.$emit('isShowCurrentDialog',data) } });
来源:https://www.cnblogs.com/Cxymds/p/17491486.html

浙公网安备 33010602011771号