我正在使用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,
}
}]
}
}
};
发布于 2019-04-11 03:49:27
在摆弄了一段时间后,我找到了解决方案zeroLineColor:‘透明’做到了这一点。在这里找到的https://github.com/chartjs/Chart.js/issues/3950
scales: {
xAxes: [{
gridLines: {
zeroLineColor: 'transparent'
},
}],
https://stackoverflow.com/questions/55624343
复制相似问题