admin管理员组文章数量:1321816
I have simple line graph which is show some progress. There are dates on x-axis a and status (1 to 5) on y-axis. Data will always be from 1 to 5. But what I need is to change labels on y-axis (and labels on point hover too) from numbers to showing progress by text string. For example where is 1 a I need text string with "request added", on 2 "request viewed", on 3 "request accepted" on 4 "request solved" and on 5 "solving confirmed". I think there is no native way to achieve this, but maybe someone will know how to edit Chart.js to make it.
Here is a picture how it looks now, with these number: screenshot
Sorry for my english and thx for any help!
I have simple line graph which is show some progress. There are dates on x-axis a and status (1 to 5) on y-axis. Data will always be from 1 to 5. But what I need is to change labels on y-axis (and labels on point hover too) from numbers to showing progress by text string. For example where is 1 a I need text string with "request added", on 2 "request viewed", on 3 "request accepted" on 4 "request solved" and on 5 "solving confirmed". I think there is no native way to achieve this, but maybe someone will know how to edit Chart.js to make it.
Here is a picture how it looks now, with these number: screenshot
Sorry for my english and thx for any help!
Share Improve this question asked Apr 17, 2015 at 13:03 Adam VýbornýAdam Výborný 7312 gold badges6 silver badges16 bronze badges 2-
Why can't you use the
label
attribute? – Jean-Paul Commented Apr 17, 2015 at 13:06 - @Jean-Paul beacuse label att is on x-axis – Adam Výborný Commented Apr 17, 2015 at 13:15
1 Answer
Reset to default 5You can use the scaleLabel function. Have a look here https://stackoverflow./a/28700578/909535
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';
}
本文标签: javascriptChartjsy axis custom labelStack Overflow
版权声明:本文标题:javascript - Chart.js - y axis custom label - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742105850a2421016.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论