如何删除 Chart.js x 轴底线?
How to remove the Chart.js x Axis bottom line?
我正在使用 Chart.js 2.8.0 试图摆脱 X/Y 轴边界。
使用 gridLines { showBorder: false }}
我仍然看到 X 轴边框。
我还将颜色设置为 0 alpha,X 和 Y 上的所有其他线都消失了,除了 X 轴上的底部线不会消失。
尝试一些其他选项,如 drawBorder: false
和 scaleLineColor: "rgba(0,0,0,0)",
none 影响 X 轴上的底线。
这是我的图表配置
type: 'line',
data: {
datasets: [{
label: '',
data: [],
backgroundColor: [],
borderWidth: 1
}]
},
options: {
scaleLineColor: "rgba(0,0,0,0)",
layout: {
padding: {
top: 20
}
},
legend: {
display: false
},
scales: {
gridLines: {
showBorder: false
},
xAxes: [{
gridLines: {
color: "rgba(0, 0, 0, 0)",
}
}],
yAxes: [{
gridLines: {
color: "rgba(0, 0, 0, 0)",
},
ticks: {
beginAtZero: true,
display: false,
}
}]
}
}
};
经过一段时间的摆弄,我找到了解决方案 zeroLineColor: 'transparent' 成功了。在这里找到它 https://github.com/chartjs/Chart.js/issues/3950
scales: {
xAxes: [{
gridLines: {
zeroLineColor: 'transparent'
},
}],
谁在使用 recharts 模块的答案:
<XAxis strokeOpacity={0} dataKey="name" />
如果有人在使用 v3 并正在寻找答案,请 options.scales.x.grid.drawBorder: false
这是在 v3.7.1 上通过查看打字稿文件并尝试任何看起来相关的东西完全偶然发现的。
我正在使用 Chart.js 2.8.0 试图摆脱 X/Y 轴边界。
使用 gridLines { showBorder: false }}
我仍然看到 X 轴边框。
我还将颜色设置为 0 alpha,X 和 Y 上的所有其他线都消失了,除了 X 轴上的底部线不会消失。
尝试一些其他选项,如 drawBorder: false
和 scaleLineColor: "rgba(0,0,0,0)",
none 影响 X 轴上的底线。
这是我的图表配置
type: 'line',
data: {
datasets: [{
label: '',
data: [],
backgroundColor: [],
borderWidth: 1
}]
},
options: {
scaleLineColor: "rgba(0,0,0,0)",
layout: {
padding: {
top: 20
}
},
legend: {
display: false
},
scales: {
gridLines: {
showBorder: false
},
xAxes: [{
gridLines: {
color: "rgba(0, 0, 0, 0)",
}
}],
yAxes: [{
gridLines: {
color: "rgba(0, 0, 0, 0)",
},
ticks: {
beginAtZero: true,
display: false,
}
}]
}
}
};
经过一段时间的摆弄,我找到了解决方案 zeroLineColor: 'transparent' 成功了。在这里找到它 https://github.com/chartjs/Chart.js/issues/3950
scales: {
xAxes: [{
gridLines: {
zeroLineColor: 'transparent'
},
}],
谁在使用 recharts 模块的答案:
<XAxis strokeOpacity={0} dataKey="name" />
如果有人在使用 v3 并正在寻找答案,请 options.scales.x.grid.drawBorder: false
这是在 v3.7.1 上通过查看打字稿文件并尝试任何看起来相关的东西完全偶然发现的。