7👍
Spent an hour and still can’t find the proper label padding options.
My workaround is padding the labels with newlines and spaces:
['行業競爭情況', ''],
['擁有專利', ''],
' 成本控制',
' 現金流',
['', '回本期'],
['', '營運能力'],
['', '行業潛力'],
'行業網絡 ',
'團隊經驗 ',
['計劃的完整性', ''],
Make it auto if you wish:
scale: {
pointLabels: {
callback: function (label, i, labels) {}...
3👍
I have the same problem as described in the question and also was unable to find a solution using known chart options.
However, here is another workaround to achieve a behaviour similar to the desired padding (although not exactly):
ticks: {
display: false,
max: 11, // notice how this is +1 more than what you actually want
},
gridLines: {
display: true,
color: [
"#dddddd", "#dddddd", "#dddddd", "#dddddd", "#dddddd",
"#dddddd", "#dddddd", "#dddddd", "#dddddd", "#dddddd",
"transparent" ], // notice how the last (additional) line is set to transparent
},
angleLines: {
display: true,
color: "#dddddd",
},
The idea is to add one additional grid line with a transparent color. While this does not cause any padding between the pointLabels and the angleLines, it does cause there to be one gridLine worth of space between the label and the next gridLine. To me, this at least looks a little better.
Note that this is only feasible if you do not need to display ticks (or if you are ok with your scale showing one additional tick value that you don’t actually use).
2👍
1👍
I use chart.js 2.6.0.
I suffered from the same problem as you.
I use only the radar type chart and amended as follows.
// chart.js v2.6.0
function adjustPointPositionForLabelHeight(angle, textSize, position) {
console.log(position.y);
if (angle === 90 || angle === 270) {
position.y -= (textSize.h / 2);
} else if (angle > 270 || angle < 90) {
position.y -= textSize.h;
position.y -= 7; //add source
}
}
1👍
Whenever my PR will be merged, pointLabels.padding
option will be added 😉
0👍
Usually problem occurs with the first pointLabel
when it is single liner you can add the callback in options as follows
pointLabels: {
callback: function (label, index) {
/* Hack to add spacing between first pointLabel item and radar graph */
return index == 0 && label.length == 1? [''].concat(label): label;
}
Making pointLabel
multi line text solves the problem.
EDIT:
Current version of chartjs
is 2.7.3
. Upcoming version will probably solves this problem.
0👍
var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
-> var pointLabelPosition = scale.getPointPosition(i, outerDistance + 15);