score: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) {}...
score:0
Whenever my PR will be merged, pointLabels.padding
option will be added ;)
score: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.
score:0
var pointLabelPosition = scale.getPointPosition(i, outerDistance + 5);
-> var pointLabelPosition = scale.getPointPosition(i, outerDistance + 15);
score:0
score: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
}
}
score: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).
Source: stackoverflow.com
Related Query
- Chart.js2 Radar, how to configure the label padding/spacing?
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- PrimeNg bar chart how to show a label for the y-axis
- How to change the label and grid line position on a timeseries chart in Chart.js 3?
- how to label axis within radar chart with chart.js
- chart.js: How do I make the radar chart axis labels bigger?
- How to rotate the Label text in doughnut chart slice vertically in chart.js canvas, Angular 12?
- Chart JS, ng2-Charts - How to make the label to the right of pie chart instead on top?
- How to scale label size radar chart chart.js
- Chartjs Radar chart - How to dynamically highlight one of the gridlines at a specific point
- How can I reduce the spacing between my legend and chart proper in my Chart.JS bar chart, and increase it in the graph area?
- How to show symbols after the label and before the numeric value using chart.js Bar chart in Angular
- How to increase the spacing between labels and the chart
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- How can I put my label on the right hand side of my chart in Chartjs
- How to configure chart.js line chart with very low minimum height, and only 0 and 1 (no decimals) as ticks on the y-axis
- How can i get the Chart JS Bar Graph Bar Label and Value on click?
- Chart js - Line chart - How to hide the data label on the line?
- Chart.js - How to Add Text in the label of the Chart with JavaScript?
- How to add text inside the doughnut chart using Chart.js?
- How do you hide the title of a chart tooltip?
- How to add text in centre of the doughnut chart using Chart.js?
- chart js tooltip how to control the data that show
- How to change the color of Chart.js points depending on the label
- Chart js. How to align text by the center of the tooltip?
- Chart JS show multiple data points for the same label
- How do I change the 'months' language displayed on the date axis in Chart JS?
- How to align Chart.JS line chart labels to the center
- How can I remove extra whitespace from the bottom of a line chart in chart.js?
- How to add padding to the vertical scale (X-axis) in Chart.js?
More Query from same tag
- Chart area background color chartjs
- Line chart with large number of labels on X axis
- Align data label right. Horizontal bar chart Vue JS
- Always show last tooltip on all datasets, leave the rest to display on hover? ChartJS
- Chart.js tooltip background color setting
- Full width bars in Chart.js version 2.7.2
- error : "Uncaught TypeError: Cannot read property 'length' of null" Chart.js
- Chart JS - single lines (points) tooltips
- Vertical Punchcard with chartjs
- automatic legend translation on chart.js
- Which is the appropriate lifecycle hook to draw a line?
- Want to save chart.js charts to image using django cron job
- In Stacked horizontal bar chart how to remove the vertical line in Chart.js?
- Chartjs removing labels and begin number
- JavaScript array value to chart.js graph as stacked graph
- Show statistics in my diagram (php mysqli)
- Customizing Chart.js troubleshoot
- ChartJS creating var takes each character and outputs undefined
- Right way to Plot Dynamic Grouped Bar chart.js
- How to make dynamic chart js using JSON in Codeigniter?
- Make Chart.js horizontal bar labels multi-line
- hide label on doughnut chart of chartjs
- Chart.js how to display multiple labels on multi bar stacked chart
- passing each element of array in the labels of char.js
- How to make Laravel Charts
- Export chart.js canvas to prawn-pdf in rails
- Remove Decimal like " [Decimal('1220'), Decimal('160')] "from Django Queryset results
- multiple horizontal bar charts to display in same row
- Display Json from Node.js in Chart.js with React
- Is there any way to show a tooltip for points which are not visible on the chart in Chart.js?