配置项如下
dataObj = {
year: ['9月27日', '9月28日', '9月29日', '9月30日','10月1日','10月2日','10月3日'],
data: {
value: [{
name: '接诊数',
value: [2580, 2444, 2420, 2278, 2227, 1237,1344]
}, {
name: '病历数',
value: [2227, 2124, 2070, 1878, 1527, 1757,1654]
}, {
name: '处方',
value: [1427, 1274, 1220,1499, 1230, 1355,1221]
}]
}
}
let dataArr = []
dataObj.data.value.map(item => {
let datachild = []
let newArr = {
name: item.name,
type: 'line',
smooth: true,
symbolSize: 8,
data: item.value,
barWidth: '30%',
itemStyle: {
normal: {
color: item.name ==='接诊数'?'#f0c725':item.name ==='病例数'?'#0BE3FF':'#16f892'
}
}
}
dataArr.push(newArr)
})
option = {
backgroundColor: '#12193a',
color: ['#f0c725', '#16f892'],
title: {
left: 'center',
text: '学生活跃度分析',
textStyle: {
color: '#FFFFFF',
fontSize: '14',
}
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
x: 'center',
top: '25',
textStyle: {
color: '#c1cadf',
"fontSize": 14
}
},
grid: {
left: '6%',
right: '4%',
top: '25%',
bottom: '3%',
containLabel: true
},
toolbox: {
show: true,
orient: 'vertical',
x: 'right',
y: 'center'
},
xAxis: [{
type: 'category',
boundaryGap: false,
data: dataObj.year,
axisLine: {
lineStyle: {
color: 'rgba(240,199,37,0.5)'
}
},
axisLabel: {
interval: 0,
color: '#c1cadf',
fontSize:'15'
}
}],
yAxis: [{
type: 'value',
name: '人数',
min:0,
max:3000,
nameTextStyle: {
color: '#c1cadf',
align: 'right',
lineHeight: 10
},
axisLine: {
lineStyle: {
color: 'rgba(240,199,37,0.5)'
}
},
axisLabel: {
interval: 0,
color: '#c1cadf',
fontSize:'15'
},
splitLine: {
show: false
}
}],
series: dataArr
};