Chart.js v2 - hiding grid lines

后端 未结 7 1998
旧时难觅i
旧时难觅i 2020-12-12 15:25

I am using Chart.js v2 to draw a simple line chart. Everything looks fine, except there are grid lines that I don\'t want:

The documentation for Line Chart

7条回答
  •  眼角桃花
    2020-12-12 15:46

    I found a solution that works for hiding the grid lines in a Line chart.

    Set the gridLines color to be the same as the div's background color.

    var options = {
        scales: {
            xAxes: [{
                gridLines: {
                    color: "rgba(0, 0, 0, 0)",
                }
            }],
            yAxes: [{
                gridLines: {
                    color: "rgba(0, 0, 0, 0)",
                }   
            }]
        }
    }
    

    or use

    var options = {
        scales: {
            xAxes: [{
                gridLines: {
                    display:false
                }
            }],
            yAxes: [{
                gridLines: {
                    display:false
                }   
            }]
        }
    }
    

提交回复
热议问题