2020-12-18 echarts 点击空白区域

echarts getZr()方法是监听整个画布  配合点击事件使用就可以点击echarts图空白区域

 const bimAxisDom: any = this.$refs.threeModelAxis
        this.bimAxisChart = echarts.init(bimAxisDom as HTMLCanvasElement)
        let _this = this
        // 点击
        this.bimAxisChart.getZr().on('click', (params: any) => {
            const pointInPixel = [params.offsetX, params.offsetY]
            if (this.bimAxisChart.containPixel('grid', pointInPixel)) {
                _this.xIndex = this.bimAxisChart.convertFromPixel({ seriesIndex: 0 }, [params.offsetX, params.offsetY])[0]
                _this.mouseDown()
            }
        })

猜你喜欢

转载自blog.csdn.net/qq_39139322/article/details/111369007