I'm currently using Chart.js and building a radar graph in my project with some dynamic data. It is working fine. However, the users occasionally use too many characters in their labels and this affects the overall size of the graph.
Is there a way of reducing the outer ring labels to say:
"This is a really long label" to "This is a ... "
Without affecting the label within the graph itself (the hover label)?
I did think of something like:
var label = "This is a really long label";
newLabel = label.substring(0,8) + "...";
Giving: This is ...
However this will affect both the label on the outside of the radar graph and also the interior hover label. I just want the outer label fixed.
答案 0 :(得分:0)
只需设置scaleLabel
功能
...
options: {
scale: {
pointLabels: {
callback: function(pointLabel) {
if (pointLabel.length > 6)
return pointLabel.substring(0, 5) + '...';
else
return pointLabel
}
}
}
}
...