Echarts histogram click event implementation

  1. Click events on posts (for post binding events only)
myChart.setOption(this.option); myChart.off().on("click", params => { ... According to params can get click column information for operation}});Copy the code
  1. Click event of Cavans (for the whole Canvas binding event, click the shadow area of the column can also obtain the corresponding data information)
myChart.setOption(this.option); myChart.getZr().off("click"); Mychart.getzr ().on("click", params => {const pointInPixel = [params.offsetx, params.offsety]; If (mychart.containpixel ("grid", pointInPixel)) {mychart.containpixel ("grid", pointInPixel) y] const yIndex = myChart.convertFromPixel({ seriesIndex: 0 }, [params.offsetX, params.offsetY])[1]; . According to [x, y] can obtain click column information for operation}});Copy the code

ContainPixel, convertFromPixel