配置项如下
var y1Max = 100, y2Max = 100;
var myxAxisData = ['05-11','05-12','05-13','05-14','05-15','05-16','05-17'];
var myData1 = [28,25,27,26,33,33,33];
var myData2 = [82,71,79,84,99,89,89];
option = {
title: {
text: '最近一周趋势',
textStyle: {
fontWeight: 'bold',
fontSize: 12
},
padding: [15, 0, 0, 0]
},
legend: {
data: ['数量', '比例'],
right: 0,
padding: [15, 0, 0, 0]
},
xAxis: {
data: myxAxisData,
axisLabel: {
textStyle: {
color: '#000'
}
},
axisTick: {
show: true
},
axisLine: {
show: true
},
z: 10
},
yAxis: [{
type: 'value',
name: '数量',
min: 0,
max: y1Max,
position: 'left',
splitLine: {
show: false
}
}, {
type: 'value',
name: '比例',
min: 0,
max: y2Max,
position: 'right',
axisLabel: {
formatter: '{value}%'
},
offset: -6,
splitLine: {
show: false
}
}],
series: [{
name: '数量',
type: 'bar',
barWidth: 18,
yAxisIndex: 0,
label: {
normal: {
color: '#73cafd',
show: true,
position: 'top'
}
},
itemStyle: {
normal: {
color: '#73cafd'
}
},
data: myData1
}, {
name: '比例',
type: 'line',
yAxisIndex: 1,
label: {
normal: {
textStyle: {
color: '#999',
},
show: true,
position: 'top',
formatter: '{c}%'
}
},
lineStyle: {
normal: {
color: '#999',
width: 3,
shadowColor: 'rgba(0,0,0,0.4)',
shadowBlur: 10,
shadowOffsetY: 10
}
},
data: myData2
}]
}