altoids altoids - 2 months ago 10
Javascript Question

How do I remove the y-axis labels from a graph?

I'm working on a line graph using Chart.js, I need to create a graph like the image below.

My problem is how do I remove the y-axis labels and add a vertical one instead?

This is the code I have for the vertical y-axis text

var options = {
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: "Normalized/Indexed Data",

}
}]

}
}


But how do I remove the other labels (1.0, 1.5, 2.0 ...)
enter image description here

enter image description here

Answer

You can add ticks:{ display: false }. Docs

var options = {
  scales: {
    yAxes: [{
      scaleLabel: {
        display: true,
        labelString: "Normalized/Indexed Data",

      },
      ticks:{
        display: false
      }
    }]

  }
}