I want to make a chart which has percentage values on y-axis but I'm not able to find any options in document. Please suggest some answers
You could do something like this:
If you know the absolute value that represents 100% in your dataset, you can pass this to your options object:
scales: {
yAxes: [
{
ticks: {
min: 0,
max: this.max,// Your absolute max value
callback: function (value) {
return (value / this.max * 100).toFixed(0) + '%'; // convert it to percentage
},
},
scaleLabel: {
display: true,
labelString: 'Percentage',
},
},
],
},
If you have a static total...say a max value of 800, you can just show custom ticks like this:
ticks: {
//.. Other settings
stepSize: 200, /* total/4 shows 0, 25%, 50%, 75%, 100% */
callback: function(value, index, values) {
return ((value / 800) * 100) + '%';
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With