配置项如下
var dataAxis = ['一', '二', '三'];
var data1 = [220, 182, 191];
var data2 = [20, 164, 127];
var dataShadow = Array.from({
length: 3
}).fill(500);
option = {
xAxis: Array.from({
length: 2
}).fill({
data: dataAxis,
position: 'bottom',
axisLabel: {
// textStyle: {
// color: '#fff'
// }
},
axisTick: {
show: false
},
axisLine: {
show: false
},
zlevel: 10,
}),
yAxis: {
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
textStyle: {
color: '#999'
}
}
},
series: [{
type: 'bar',
barGap: '30%',
barWidth: 20,
xAxisIndex: 1,
itemStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[{
offset: 0,
color: '#83bff6'
},
{
offset: 0.5,
color: '#188df0'
},
{
offset: 1,
color: '#188df0'
}
]
),
shadowColor: 'rgba(0, 0, 0, 0.5)',
shadowBlur: 10
},
data: data2
},
{
type: 'bar',
barWidth: 20,
xAxisIndex: 1,
itemStyle: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[{
offset: 0,
color: '#83bff6'
},
{
offset: 0.5,
color: '#188df0'
},
{
offset: 1,
color: '#188df0'
}
]
),
shadowColor: 'rgba(0, 0, 0, 0.5)',
shadowBlur: 10
},
data: data1
},
{ // For shadow
xAxisIndex: 0,
type: 'bar',
itemStyle: {
color: 'rgba(0,0,0,0.05)'
},
data: dataShadow,
barGap: '150%',
barWidth: 60,
},
]
};