点击echarts折线图拿到对应的x轴 首先在设置图表选项之后添加点击事件拿到点击的offsetX, offsetY通过下方计算得到X坐标我这里的x轴为月份chartInstance.setOption(option)// 设置图表选项 chartInstance.off(click) chartInstance.getZr().on(click, (params: any) { const pointInPixel [params.event.offsetX, params.event.offsetY] // 像素坐标转逻辑坐标 const pointInGrid chartInstance!.convertFromPixel(grid, pointInPixel) const xIndex Math.round(pointInGrid[0]) // 边界校验防止超出月份范围 if (xIndex 0 xIndex props.chartData.monthList.length) { const month props.chartData.monthList[xIndex] const value props.chartData.valueList[xIndex] // console.log({ index: xIndex, month, value }); emit(monthClick, month, value) } })