1、解决方法
barCategoryGap用来设置类目间柱形距离,默认为类目间距的20%,可设固定值,调整这个值,可实现柱间距离
2、源码
var colorList_series1 = [ '#49af68', '#387fcf', '#f08d3d', '#36abb9' ];
var colorList_series2 = [ '#8bcc9f', '#6a9fdb', '#f4aa6e', '#8cced7' ];
option = {
tooltip : {
trigger : 'axis'
},
grid : {
x : '50%',
y : '16%',
x2 : '20%',
y2 : '17%',
borderWidth : 1,
borderColor : '#eeeeee',
},
legend : {
data : [ '系列1', '系列2' ]
},
calculable : true,
xAxis : [ {
type : 'category',
data : [ '1月', '2月', '3月', '4月' ]
} ],
yAxis : [ {
type : 'value'
} ],
series : [ {
name : '系列1',
type : 'bar',
barWidth : 30,
itemStyle : {
normal : {
color : function(params) {
return colorList_series1[params.dataIndex];
}
}
},
data : [ 2.0, 4.9, 7.0, 23.2 ],
}, {
name : '系列2',
type : 'bar',
barWidth : 15,
itemStyle : {
normal : {
color : function(params) {
return colorList_series2[params.dataIndex];
}
}
},
data : [ 2.6, 5.9, 9.0, 26.4 ],
} ]
};
3、效果显示