有一个react专用的包
import ReactEcharts from 'echarts-for-react';
const getOptionPower = () => {
let option = {
tooltip: {
trigger: 'axis'
},
legend: {
data: ['逆变器数值', '多功能表数值']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
dataZoom: [ // 区域缩放底部的缩放控件
{
type: 'inside'
},
{
type: 'slider'
}
],
xAxis: {
type: 'category',
boundaryGap: false,
axisLabel: {
showMaxLabel: true
},
data: echartData.dateList
},
yAxis: {
type: 'value'
},
series: [
{
name: '逆变器数值',
type: 'line',
stack: 'Total',
data: echartData.inverterDataList
},
{
name: '多功能表数值',
type: 'line',
stack: 'Total',
data: echartData.multiDataList
},
]
};
return option
}
<ReactEcharts option={getOptionPower()}/>