配置项如下
option = {
title: {
left: 'center',
top: '0%'
},
tooltip: {
trigger: 'axis',//axis item
axisPointer: {
lineStyle: {
color: 'rgba(211, 213, 217, 1)',
width: 2
}
}
},
color: ['#49a93e', '#5b9bd5', '#ed7d31'],
legend: {
bottom: '0'
},
grid: {
left: '3%',
right: '3%',
bottom: '8%',
top: '20%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: []
},
yAxis: [
{
type: 'value',
// offset: 20,
splitLine: {
show: false
},
axisTick: {
length: 0
},
axisLine: {
show: false
},
axisLabel: {
show: false
}
},
{
type: 'value',
show: false,
inverse: true,
min: 1,
max: 0
}
],
smooth: true,
series: [
{
type: 'bar',
yAxisIndex: 1,
barWidth: '36%',
barMinHeight: 1,
data: [{value:0,name:-4},{value: 0,name:-4},{value: 0,name:-4},{value:0,name:4},{value:0,name:-5}],
itemStyle: {
normal: {
color: function (params) {
if (params.data.name < 0) {
return '#ffb1b1';
} else {
return '#49a93e';
}
}
}
},
label: {
normal: {
show: true,
position: 'top',
formatter:function(params){
return params.name
}
}
}
},
{
type: 'line',
label: {
normal: {
show: true,
position: 'left',
textStyle: {
color: '#ed7d31'
},
offset: [0, -4]
}
},
itemStyle: {
normal: {
color: '#ed7d31'
}
},
smooth: true,
data: [14,12,8,19,12]
},
]
};