安装依赖
npm install --save echarts-for-react
npm install --save echarts
基本使用
import ReactEcharts from 'echarts-for-react';
const Demo = () => {
const getOption = {
grid: {
top: 80, right: 36, bottom: 70, left: 38,
},
title: [
{
text: '',
left: 'lefter',
},
],
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',
},
],
};
return <>
<ReactEcharts
style={{
height: '430px',
width: '1200',
border: '1px solid #dadada',
}}
option={getOption}
/>
</>
}
文档