Solve the problem that the number of echarts histograms is too small and the click event does not take effect

20210428094354203.png (1001×753)

 

myChart4.getZr().on('click',function (params) {
  let pointInPixel= [params.offsetX,params.offsetY];
  if(myChart4.containPixel('grid',pointInPixel)){
    let pointInGrid=myChart4.convertFromPixel({seriesIndex: 0},pointInPixel);
    let xIndex=pointInGrid[0] //获取下标
  }
})

Close the click event of echarts, get the xIndex column through the click position, 0 represents the 1st column, and then use this to find your local data to complete the click effect.

Guess you like

Origin blog.csdn.net/weixin_60196946/article/details/131961457