11

I managed to remove all horizontale lines/rules in my chart using this:

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

But I also want to get rid of the rule/bar that represents the Y-axis as well. But I want to keep the labels:

enter image description here

Unfortunately I can't find any option for that. I can only remove the whole axis including labels.

I'm using Chart.js 2.3.

lampshade
  • 2,470
  • 3
  • 36
  • 74
  • in x axis gridLines u make it as false and looking in the y axis to display the false – Parthasarathy Nov 10 '16 at 08:31
  • 1
    @Parthasarathy The example show ho to remove the horizontal gridlines. But this option doesn't remove the actual line for the axis (horizontally or vertically doesn't matter). So I'm looking for an option how to remove the actual line of the axis not only the grid lines. – lampshade Nov 10 '16 at 08:34

9 Answers9

32

I found a way to remove this line. It's actually called the border of the axis and there's an option for it, see "Grid Line Configuration":

scales: {
    yAxes: [{
        gridLines: {
            drawBorder: false,
        }
    }]
}
lampshade
  • 2,470
  • 3
  • 36
  • 74
4

This should work

 options: {
     scales: {
          yAxes: [{
               gridLines: {
                  display: false,
              }
          }]
     },
  }
eaglebearer
  • 2,060
  • 1
  • 13
  • 9
4

This worked for me in version 2.8.0 -

scales: {
    yAxes: [{
        gridLines: {
            tickMarkLength: false,
        }
    }]
}
monika
  • 114
  • 3
4

In v3 you can do:

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

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

pegido
  • 629
  • 1
  • 8
  • 13
3

The left line is still coming from the x axis grid lines. Changing the 'zeroLineColor' of the x axis to 'transparent' hid it.

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

Source: https://github.com/chartjs/Chart.js/issues/3950

Dy4
  • 687
  • 1
  • 9
  • 20
1

In the version 4.x.x you do it like this:

options: {
  scales: {
    y: {
       border: {
        display: false,
      },
    },
    x: {
      grid: {
        drawOnChartArea: false,
      },
    },
  },
},

The border in y is the option that specifically does what you are asking. I added the x for users that also want to see how to hide the rest of the x axis lines.

jogarcia
  • 2,327
  • 2
  • 19
  • 34
0
gridLines: {zeroLineColor: 'transparent'}
Kapil Raghuwanshi
  • 867
  • 1
  • 13
  • 22
Dor Levi
  • 303
  • 2
  • 4
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/26055927) – ikos23 May 07 '20 at 12:42
  • While this code may solve the OP's issue, it is better to add context, or an explanation as to why this solves the OP's problem, so future visitors can learn from your post, and apply this knowledge to their own issues. High Quality Answers are much more likely to be upvoted, and contribute to the value and quality of SO as a platform. You can also add a link to documentation, if that helps. – SherylHohman May 07 '20 at 18:01
  • @john An answer that's not fully explained, incomplete, or just plain wrong is still an answer. If you think it's a *bad* answer, that's what downvotes are for. See [when to flag an answer as “not an answer”?](https://meta.stackoverflow.com/a/265553/1324) – Paul Roub May 07 '20 at 18:16
0

this workerd for me yAxes: [ { gridLines: { display: false, }, }, ],

Kuro Neko
  • 16
  • 2
-2

You can use the scaleLineColor: 'transparent' it will remove the y any x axis

Parthasarathy
  • 308
  • 2
  • 10