配置项如下
var myColor=['#eb2100','#eb3600','#d0570e','#d0a00e','#34da62','#00e9db','#00c0e9','#0096f3'];
option = {
backgroundColor:'#222',
grid: {
left: '2%',
top:'1%',
right: '5%',
bottom: '0%',
containLabel: true
},
xAxis: [{
show: false,
}],
yAxis: [{
axisTick:'none',
axisLine:'none',
offset:'7',
axisLabel: {
textStyle: {
color: 'rgba(255,255,255,.6)',
fontSize:'14',
}
},
data: ['建始','利川','红庙','鹤峰', '巴东', '咸丰','恩施中支', '来凤','宣恩']
}, {
axisTick:'none',
axisLine:'none',
axisLabel: {
textStyle: {
color: 'rgba(255,255,255,.6)',
fontSize:'14',
}
},
data: [2456, 4664, 3506,1619,1968,2158 ,8390,1623,1514]
},{
name:'单位:件',
nameGap:'50',
nameTextStyle:{
color: 'rgba(255,255,255,.6)',
fontSize:'16',
},
axisLine:{
lineStyle:{
color:'rgba(0,0,0,0)'
}
},
data: [],
}],
series: [{
name: '条',
type: 'bar',
yAxisIndex: 0,
data: [8.8,16.72,12.57,5.8,7.05,7.74,30.07,5.82,5.43],
label:{
normal:{
show:true,
position:'right',
formatter:function(param){
return param.value + '%';
},
textStyle:{
color: 'rgba(255,255,255,.8)',
fontSize:'12',
}
}
},
barWidth: 20,
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
offset: 0,
color: '#03c893'
},
{
offset: 1,
color: '#0091ff'
}
]),
barBorderRadius: 5,
}
},
z: 2
}, {
name: '白框',
type: 'bar',
yAxisIndex: 1,
barGap: '-100%',
data: [99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5],
barWidth: 20,
itemStyle: {
normal: {
color:'rgba(0,0,0,.2)',
barBorderRadius:5,
}
},
z: 1
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize",function(){
myChart.resize();
});