如何删除Chart.js中轴的line/rule?

How to remove the line/rule of an axis in Chart.js?

我设法删除了图表中的所有水平线 lines/rules,方法是:

scales: {
       xAxes: [{
        gridLines: {
            display: false
        }  
    }]
}

但我也想去掉代表 Y 轴的 rule/bar。 但我想保留标签:

很遗憾,我找不到任何选项。我只能删除包括标签在内的整个轴。

我正在使用 Chart.js 2.3.

您可以使用 scaleLineColor: 'transparent' 它会删除 y 任意 x 轴

我找到了删除此行的方法。它实际上称为轴的 border 并且有一个选项,请参阅 "Grid Line Configuration":

scales: {
    yAxes: [{
        gridLines: {
            drawBorder: false,
        }
    }]
}

这应该有效

 options: {
     scales: {
          yAxes: [{
               gridLines: {
                  display: false,
              }
          }]
     },
  }
gridLines: {zeroLineColor: 'transparent'}

这在版本 2.8.0 中对我有用 -

scales: {
    yAxes: [{
        gridLines: {
            tickMarkLength: false,
        }
    }]
}

左边的线仍然来自x轴网格线。将 x 轴的 'zeroLineColor' 更改为 'transparent' 隐藏它。

xAxes:[{
gridLines:{
zeroLineColor:'transparent'
}}]

来源:https://github.com/chartjs/Chart.js/issues/3950

v3 中你可以:

options: {
  scales: {
    y: {
      grid: {
        drawBorder: false,
      }
    }
  }
}

https://www.chartjs.org/docs/master/axes/styling#grid-line-configuration

这对我有用 yAxes: [ { gridLines: { display: false, }, }, ],