Chart.js - custom y-axis label

I have a simple line graph that shows some progress. The x-axis shows the dates and the state (1 to 5) along the Y-axis. The data will always be 1 to 5. But I need to change the Y-labels (and the dot-hover labels too) from numbers to showing progress on the text line. For example, where 1 a I need a text string with "added request", 2 "requested requests", 3 "requested request", 4 "request allowed" and 5 "resolved solution". I think there is no native way to do this, but maybe someone will know how to edit Chart.js to do this.

Here is the image as it looks now with this number: screenshot

Sorry for my english and thanks for any help!

+3


source to share


1 answer


You can use the scaleLabel function. Take a look here fooobar.com/questions/140288 / ...



scaleLabel: function (valuePayload) {
if(Number(valuePayload.value)===1)    
return 'request added';
if(Number(valuePayload.value)===2)    
return 'request viewed';
if(Number(valuePayload.value)===3)    
return 'request accepted';
if(Number(valuePayload.value)===4)    
return 'request solved';
if(Number(valuePayload.value)===5)    
return 'solving confirmed';
}

      

+4


source







All Articles