click事件
onChartClick=(param,echarts)=>{ console.log(param) } render(){ let onEvents={ ‘click‘: this.onChartClick } return( <ReactEcharts option={this.getOption()} notMerge={true} lazyUpdate={true} onEvents={onEvents} style={{width: ‘100%‘,height:‘100%‘}} /> ) }
legend标签点击事件
onChartLegendselectchanged=(param,echarts)=>{ console.log(param) } render(){ let onEvents={ ‘legendselectchanged‘: this.onChartLegendselectchanged } return( <ReactEcharts option={this.getOption()} notMerge={true} lazyUpdate={true} onEvents={onEvents} style={{width: ‘100%‘,height:‘100%‘}} /> ) }
npm install --save echarts-for-react
//如果需要使用echarts的一些特殊方法需要安装
npm install --save echarts
import ReactEcharts from ‘echarts-for-react‘;
import echarts from ‘echarts‘;
<ReactEcharts
option={this.getOption()}
notMerge={true}
lazyUpdate={true}
onEvents={onEvents}
style={{width: ‘100%‘,height:‘100%‘}}
/>
原文:https://www.cnblogs.com/ningmengya/p/14356319.html