安装插件
npm install echarts --save
npm i echarts-for-react
组件内使用
import React from 'react'
import ReactECharts from 'echarts-for-react';
export default function index() {
const option = {
title: {
text: 'ECharts Example'
},
tooltip: {},
xAxis: {
data: ['A', 'B', 'C', 'D', 'E', 'F']
},
yAxis: {},
series: [
{
name: 'Sales',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}
]
};
return (
<div>
<h1>柱状图</h1>
<ReactECharts option={option} style={{ height: 400, width: '100%' }} />
</div>
)
}