Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use percentage scale with Chart.js

I tried to look it up in the documentation (all examples I found elsewhere did not work anymore, probably due to an outdated syntax for earlier versions) how to use "scaleLabel", but there it references to the scale title configuration with a link which does not exist (anymore): http://www.chartjs.org/docs/#scale-title-configuration

Can someone please provide a working example?

like image 980
Simon Ferndriger Avatar asked Oct 31 '16 09:10

Simon Ferndriger


1 Answers

Scale title configuration is a header if you scroll down in the documentation.

Here is a simple bar chart example, using scaleLabel which is sligtly modified to illustrate a percentage.

https://jsfiddle.net/r71no58a/4/

scales: {
   yAxes: [{
       ticks: {
           min: 0,
           max: 100,
           callback: function(value) {
               return value + "%"
           }
       },
       scaleLabel: {
           display: true,
           labelString: "Percentage"
       }
   }]
}
like image 135
Tom Glover Avatar answered Oct 12 '22 14:10

Tom Glover