«

react实现柱状图点击阴影 react echarts阴影点击

emer 发布于 2019-6-26 10:48   2952 次阅读     


render(){

return(
<div>
<EchartsReact option={option} ref={(e) => {
this.echartsReactRef = e;//chu
}} style={{height:2+"rem",width:'100%'}}/>
</div>
)

}

componentDidMount() {
this.echartsInstance = this.echartsReactRef.getEchartsInstance();
this.zr = this.echartsInstance.getZr();

this.zr.on('click', (...rest) => {
var pointInPixel= [rest.offsetX, rest.offsetY];
var xIndex=this.echartsInstance.convertFromPixel({seriesIndex:0},[rest[0].offsetX, rest[0].offsetY]);
var index=parseInt(xIndex);
console.log(index);
console.log('App:onClickChart', rest);
});
}