我设法使用以下方法删除了图表中的所有水平线/规则:
scales: {
xAxes: [{
gridLines: {
display: false
}
}]
}
但我也想摆脱代表 Y 轴的规则/条。但我想保留标签:
不幸的是,我找不到任何选择。我只能删除包括标签在内的整个轴。
我正在使用 Chart.js 2.3。
我设法使用以下方法删除了图表中的所有水平线/规则:
scales: {
xAxes: [{
gridLines: {
display: false
}
}]
}
但我也想摆脱代表 Y 轴的规则/条。但我想保留标签:
不幸的是,我找不到任何选择。我只能删除包括标签在内的整个轴。
我正在使用 Chart.js 2.3。
我找到了删除这条线的方法。它实际上被称为border
轴的,并且有一个选项,请参阅“网格线配置”:
scales: {
yAxes: [{
gridLines: {
drawBorder: false,
}
}]
}
这应该工作
options: {
scales: {
yAxes: [{
gridLines: {
display: false,
}
}]
},
}
这在 2.8.0 版中对我有用-
scales: {
yAxes: [{
gridLines: {
tickMarkLength: false,
}
}]
}
左边的线仍然来自 x 轴网格线。将 x 轴的 'zeroLineColor' 更改为 'transparent' 隐藏它。
xAxes:[{
gridLines:{
zeroLineColor:'transparent'
}}]
在v3中,您可以执行以下操作:
options: {
scales: {
y: {
grid: {
drawBorder: false,
}
}
}
}
https://www.chartjs.org/docs/master/axes/styling#grid-line-configuration
gridLines: {zeroLineColor: 'transparent'}
这个为我工作
yAxes: [ { gridLines: { display: false, }, }, ],
You can use the scaleLineColor: 'transparent'
it will remove the y any x axis