Skip to content
Advertisement

How to set ChartJS Y axis title?

I am using Chartjs for showing diagrams and I need to set title of y axis, but there are no information about it in documentation.

I need y axis to be set like on picture, or on top of y axis so someone could now what is that parameter

I have looked on official website but there was no information about it

Advertisement

Answer

For Chart.js 2.x refer to andyhasit’s answer – https://stackoverflow.com/a/36954319/360067

For Chart.js 1.x, you can tweak the options and extend the chart type to do this, like so

JavaScript

calling it like this

JavaScript

Notice the space preceding the label value, this gives us space to write the y axis label without messing around with too much of Chart.js internals


Fiddle – http://jsfiddle.net/wyox23ga/


enter image description here

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement