有些柱子没有值或者由于样式问题很难点击到,需要进行区域点击联动
一般的点击方法必须选中柱子
//getZr()方法,官方文档中未标注
this.barChart1.getZr().on('click', function (params) {
let pointInPixel = [params.offsetX, params.offsetY]
if (that.barChart1.containPixel('grid', pointInPixel)) {
let pointInGrid = that.barChart1.convertFromPixel({
seriesIndex: 0
}, pointInPixel);
let yIndex = pointInGrid[1]; //索引,可取x或y轴的,当前取y轴
let handleIndex = Number(yIndex);
let seriesObj = that.barChart1.getOption(); //图表object对象
let selName = seriesObj.yAxis[0].data[handleIndex]//获取到区域点击选中的柱子的name
//that.zdryOptions.forEach(item => {
// if(selName.slice(0,4)==item.name.slice(0,4)){
// that.zdryRegionCode = item.codeId
// }
//})
}
})