option = { legend: {}, tooltip: {}, dataset: { dimensions: ['product', '2016', '2017'], source: [ { product: '1', 2016: 85.8, 2017: 93.7 }, { product: '2', 2016: 73.4, 2017: 55.1 }, { product: '3', 2016: 65.2, 2017: 82.5 }, { product: '4', 2016: 53.9, 2017: -39.1 } ] }, xAxis: { type: 'category' }, yAxis: {}, series: [ { type: 'bar' }, { type: 'bar' }] };让两个柱子之间的距离为0
时间: 2024-04-23 17:27:33 浏览: 20
要让两个柱子之间的距离为0,你可以在 `series` 的配置项中设置 `barCategoryGap` 属性为 `'0%'`。这样可以将两个柱子之间的距离设置为0。以下是修改后的代码示例:
```javascript
option = {
legend: {},
tooltip: {},
dataset: {
dimensions: ['product', '2016', '2017'],
source: [
{ product: '1', 2016: 85.8, 2017: 93.7 },
{ product: '2', 2016: 73.4, 2017: 55.1 },
{ product: '3', 2016: 65.2, 2017: 82.5 },
{ product: '4', 2016: 53.9, 2017: -39.1 }
]
},
xAxis: { type: 'category' },
yAxis: {},
series: [
{ type: 'bar', barCategoryGap: '0%' },
{ type: 'bar', barCategoryGap: '0%' }
]
};
```
通过在每个柱状图系列的配置中设置 `barCategoryGap` 属性为 `'0%'`,两个柱子之间的距离将会变为0。这样可以实现你想要的效果。记得根据需要进行相应的配置调整。