相信大家也出现过echarts图没有铺满整个父元素的问题
确实官网中有一个grid属性 专门设置图表与父元素上下左右的距离
例如
grid: {
left: 40,
right: 0,
bottom: 40,
top: 0
},
绘图参考代码如下
myChart.setOption({
tooltip: {},
grid: {
left: 40,
right: 0
},
legend: {
top: 'bottom'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
}
},
xAxis: {
data: ["超级管理","UI","超级管理","超级管理"]
},
yAxis: {
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
series: [{
name: '部门',
type: 'bar',
data: [5, 20, 36, 10],
color: 'rgba(69,114,167)'
}]
});