npm install --save echarts-for-react
import React, { PureComponent } from 'react';
import ReactEcharts from 'echarts-for-react';
// 将echarts的某些事件,在最初的时候激活
public chartReady = (chart): void => {
chart.dispatchAction({
type: 'takeGlobalCursor',
key: 'dataZoomSelect', // 框选事件
dataZoomSelectActive: true
});
};
public render(): JSX.Element {
this.setLegendPosition('top');
return (
<ReactEcharts
// onEvents={onEvents} // 监听事件方法
// ref={(e: any) => getEchart && getEchart(e)} // 获取eChart组件实例
option={this.getOption()}
onChartReady={this.chartReady}
></ReactEcharts>
);
}
// const onChartClick = p => {
// console.log(p);
// };
// const onEvents = {
// datazoom: onChartClick
// mousedown:onChartClick
// };
// const getEchart = (e: any) => {
// if (e) {
// this.echart = e.getEchartsInstance();
// }
// };
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论