nodejs+echarts循环添加数据
定义series,将获取到的数据(data,假设为数组)通过循环push进入series中
var series = [];
for (let i=0;i<data[i].length;i++){
series.push({
name:
type: 'bar',
data: data[i]
});
option中直接调用series
option = {
title: {
text: '30天系统与各项目使用量统计'
},
xAxis: {
type: 'category',
data: date
},
yAxis: {
type: 'value'
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
legend: {
data: legend
},
series: series
};