import React, { Component } from 'react'; import echarts, { ECharts } from "echarts"; import ReactEcharts from "echarts-for-react"; export default class Test extends Component { getOpt = ()=>{ const option = { xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar', showBackground: true, backgroundStyle: { color: 'rgba(180, 180, 180, 0.2)' } }] }; return option; } componentDidMount(){ } chart : ECharts|null = null ; render(){ return ( { this.chart = ref&&ref?.getEchartsInstance() this.chart?.on("click",function(p:any){ console.log(p); }) }} /> ) } }