I am using chart.js inside of an Ionic/Angular application to build a line graph. The big problem I am running into now is that I would like to have the labels along the y axis (Green, Yellow, Orange, Red) positioned between the horizontal gridlines instead of centered on the gridlines as they are currently in the image here...
I tried using the plugin mentioned in this question with no such luck. I've also tried using the offsetGridlines property in the actual chart.js documentation again with no luck.
Free bonus points if anyone can also help out with having the actual axis line at the bottom to be the same width as the other horizontal gridlines
Here is the code that deals with this particular aspect of the chart...
options: {
legend: {
display: false
},
scaleShowVerticalLines: false,
layout: {
padding: 25
},
scales: {
xAxes: [{
gridLines: {
display: false
},
ticks: {
display: false
}
}],
yAxes: [{
gridLines: {
drawBorder: false
},
ticks: {
min: 0,
max: 100,
stepSize: 25,
fontColor: 'white',
callback: function(value) {
if (value === 25) {
return 'Red';
} else if (value === 50) {
return 'Orange';
} else if (value === 75) {
return 'Yellow';
} else if (value === 100){
return 'Green';
} else {
return '';
}
}
}
}]
}
},