Reactjs 单击图表上的数据点时启动react调用组件

Reactjs 单击图表上的数据点时启动react调用组件,reactjs,echarts,Reactjs,Echarts,我正在使用echarts和react使用echarts进行react。我想在单击图形上的一个点时调用一个组件,如何实现,以及图例是什么,我阅读了文档,但无法理解它。您可以将对象作为OneEvents道具传递给ReactEcharts组件 <ReactEcharts ref={(e) => { this.echarts_react = e; }} onEvents= {this._onEvents} /> 及 OneEvents道具无法正常工作,请尝试获取echarts

我正在使用echarts和react使用echarts进行react。我想在单击图形上的一个点时调用一个组件,如何实现,以及图例是什么,我阅读了文档,但无法理解它。

您可以将对象作为OneEvents道具传递给ReactEcharts组件

<ReactEcharts ref={(e) => { this.echarts_react = e; }}
    onEvents= {this._onEvents}
/>


OneEvents道具无法正常工作,请尝试获取echarts的ref并将事件添加到zr对象,如下所示:

import React,{Component}来自'React';
导入“/App.css”;
从“echarts for react”导入ReactEcharts;
类应用程序扩展组件{
构造函数(道具、上下文){
超级(道具、背景);
此.state={
笔迹:{
xAxis:{
类型:'类别',
数据:[周一、周二、周三、周四、周五、周六、周日]
},
亚克斯:{
类型:“值”
},
系列:[{
数据:[8209329011934013301320],
类型:“行”
}]
}
}
}
componentDidMount(){
this.echartsInstance=this.echartsReactRef.getEchartsInstance();
this.zr=this.echartsInstance.getZr();
this.zr.on('click',this.onChartClick);
}
onChartClick=(…rest)=>{
log('App:onClickChart',rest);
};
render(){
返回(
{
此.echartsReactRef=e;
}}
选项={this.state.graphOption}
/>
);
}
}
导出默认应用程序;
_onEvents = {
  'click': this.onChartClick,
  'dataZoom': this.onDataZoom,
}
onChartClick = (params)=>{
    // Do what you want to do on click event. params depend on the  type of  chart 
}