// myChart4.on("click",(e)=> { // console.log("eformychart4",e) // // // if(e.componentType=="series"){ // // myChart4.resize(); // this.getStatisticLabelEntList(e.name); // } // // })
//这种方式在柱状图里面,当数量太少是点击不到的
let that=this; myChart4.off('click'); myChart4.getZr().on('click',function (params) { console.log(params,"test654") let pointInPixel= [params.offsetX,params.offsetY]; if(myChart4.containPixel('grid',pointInPixel)){ let pointInGrid=myChart4.convertFromPixel({seriesIndex: 0},pointInPixel); let xIndex=pointInGrid[0]; console.log(xIndex,"xindex",that.option4.xAxis[0].data); myChart4.resize(); that.getStatisticLabelEntList(that.option4.xAxis[0].data[xIndex]); } })
关闭echarts的点击事件,通过点击位置获取到xIndex为第几列,0代表第1列,然后通过这个去找到你本地的数据,完成点击效果.