<div id="aa" style="height:500px;min-width:500px" ></div>
<script>
其他的省略.......
function (ec) {
var myChart = ec.init(document.getElementById('aa'));
var ecConfig = require('echarts/config');
var option = {
其他的省略 ..........
series: [ {
"name":"使用量",
"type":"bar",
stack: 'sum',
barCategoryGap: '40%',
//barWidth:30,
itemStyle: { // 系列级个性化
normal: {
// barBorderWidth: 6,
//barBorderColor:'tomato',
color: 'green'
}
},
"data":[5, 20, 40, 10, 10, 20,100,50,200,5, 20, 40, 10, 10, 20,100,50,200,100,150,150,150]
}]
</script>
为什么图表宽度不随数据增加而变宽?因为设置固定宽度当数据很少时,柱子会变得很宽
楼主你这个barWidth没有设置,所以echarts会根据你的数据个数自适应的调整当前柱子的宽度; 你的barCategoryGap: '40%目前的设定是无效的,这个barCategoryGap是不同类目间的距离,你的series目前只有一个类目,所以这个参数是不起作用的。barCategoryGap的意义