echarts - 如何在echarts中的条之间添加更多空间
问题描述
有什么方法可以在条之间添加更多空间。我不知道如何使类别之间的空间更大。我尝试了组填充,但它不起作用,请有人帮助我。
这是一天的进度表,我希望条形之间有更多的空间。
代码:
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
},
grid: {
left: '3%',
right: '4%',
bottom: '1%',
containLabel: true,
height: '90%'
},
xAxis: {
type: 'value'
},
yAxis: {
type: 'category',
data: ['9-10', '10-11', '11-12', '12-1', '1-2', '2-3', '3-4','4-5','5-6','6-7','7-8']
},
series: [
{
name: 'Active',
color: 'green',
type: 'bar',
stack: 'total',
groupPadding: 2,
label: {
show: true,
position: 'insideRight'
},
data: [20, 30, 15, 25, 10,15, 30, 30, 5, 20,10]
},
{
name: 'Inactive',
type: 'bar',
stack: 'total',
color: 'red',
groupPadding: 2,
label: {
show: true,
position: 'insideRight'
},
data: [10, 20, 30, 10, 25,10, 20, 25, 15, 30,5]
},
{
name: 'Active',
color: 'green',
type: 'bar',
stack: 'total',
groupPadding: 2,
label: {
show: true,
position: 'insideRight'
},
data: [30, 10, 15, 25, 25,35, 10, 5, 40, 10,45]
},
]
};
解决方案
您可以barCategoryGap
根据文档使用。
var myChart = echarts.init(document.getElementById('main'));
// Unsert your code below
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
},
grid: {
left: '3%',
right: '4%',
bottom: '1%',
containLabel: true,
height: '90%'
},
xAxis: {
type: 'value'
},
yAxis: {
type: 'category',
data: ['9-10', '10-11', '11-12', '12-1', '1-2', '2-3', '3-4','4-5','5-6','6-7','7-8']
},
series: [
{
name: 'Active',
color: 'green',
type: 'bar',
barCategoryGap: '50%',
stack: 'total',
groupPadding: 2,
label: {
show: true,
position: 'insideRight'
},
data: [20, 30, 15, 25, 10,15, 30, 30, 5, 20,10]
},
{
name: 'Inactive',
type: 'bar',
stack: 'total',
barCategoryGap: '50%',
color: 'red',
groupPadding: 2,
label: {
show: true,
position: 'insideRight'
},
data: [10, 20, 30, 10, 25,10, 20, 25, 15, 30,5]
},
{
name: 'Active',
color: 'green',
type: 'bar',
barCategoryGap: '50%',
stack: 'total',
groupPadding: 2,
label: {
show: true,
position: 'insideRight'
},
data: [30, 10, 15, 25, 25,35, 10, 5, 40, 10,45]
},
]
};
// Unsert your code above
myChart.setOption(option);
<script src="https://cdn.jsdelivr.net/npm/echarts@4.9.0/dist/echarts.min.js"></script>
<div id="main" style="width: 600px;height:400px;"></div>
推荐阅读
- assembly - 使用函数指针调用汇编函数
- php - 在php中将api返回的日期时间字符串从24格式转换为12小时格式
- java - iText7 将 SVG 添加到 PdfDocument 和可能的问题
- javascript - 如何使两个画布元素发生碰撞
- java - 是否可以在我的 Spring Boot Controller 类中添加“404 page not found”?
- javascript - 如何检查 vlues 是否位于特定的值范围内
- javascript - Javascript转义动态html字符串和内部字符串
- python - 在 Python 中将非常大的文件拆分为较小的文件 - 打开的文件太多
- android - 如何从 RGB 中的 android 相机获取图像?
- php - 在 wordpress 中使用 AMP 插件时,表单发布方法不起作用