注意,这是重叠,不是堆叠
代码如下(示例):
let xAxisData = []
let data1 = []
let data2 = []
let data3 = []
let data4 = []
for (let i = 0; i < 7; i++) {
xAxisData.push('Class' + i);
data1.push(+(Math.random() * 2).toFixed(2));
data2.push(+(Math.random() * 5).toFixed(2));
data3.push(+(Math.random() + 0.3).toFixed(2));
data4.push(+Math.random().toFixed(2));
}
option = {
legend: {},
xAxis: [{
data: xAxisData
}, {
show: false,
data: []
}],
yAxis: {},
tooltip: {},
series: [
{ name: '业务量(昨)', type: 'bar', xAxisIndex: 0, data: data1 },
{ name: '业务量(今)', type: 'bar', xAxisIndex: 1, data: data2 },
{ name: '金额(昨)', type: 'bar', xAxisIndex: 1, data: data3 },
{ name: '金额(今)', type: 'bar', xAxisIndex: 0, data: data4 }
]
}
效果如下(示例):