To render an ECharts chart in a React application, import ReactECharts from echarts-for-react and pass an option object containing your ECharts configuration to the component.
import React from 'react';
import ReactECharts from 'echarts-for-react';
const Page: React.FC = () => {
const options = {
grid: { top: 8, right: 8, bottom: 24, left: 36 },
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true,
},
],
tooltip: {
trigger: 'axis',
},
};
return <ReactECharts option={options} />;
};
export default Page;