-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No padding between rotated x-axis labels #2750
Comments
P.S. I also noticed the bars are wider in v2.1.4 than in v1.0.2. Is there a way to control the width in v2.1.4? Update: never mind, I found the |
@airblade you could try using the options: {
scales: {
xAxes: [{
ticks: {
minRotation: 45 // angle in degrees
}
}]
}
} You could also try a different implementation of afterCalculateTickRotation var options = {
scales: {
xAxes: [{
afterCalculateTickRotation: function(scale) {
if (scale.labelRotation !== 0) {
scale.labelRotation += 15;
}
}
}],
}
}; |
I prefer your second suggestion though, like my original workaround, it doesn't address the actual spacing between labels. Am I right in thinking that's controlled by the conditionals in this loop? while (labelWidth > tickWidth && this.labelRotation < optionTicks.maxRotation) { Would an amendment like this be possible? while (labelWidth > tickWidth + 6 && this.labelRotation < optionTicks.maxRotation) { |
Looks like the line where the tickWidth is calculated has an error: https://github.com/chartjs/Chart.js/blob/v2.1.4/src/core/core.scale.js#L219 I think the |
I'm not familiar with the code but, going by the code comment, I think you might be right. By the way, where do the 2 lots of 3px padding apply? Is it above and below the rotated label, at right angles to the rotated baseline? |
It looks like the 3px are added to the width, so it would be along the rotated baseline. We should probably add a configurable padding that is perepndicular to the baseline |
Hello! I'm using Chart.js v2.1.4. Thank you for the great code :)
I have a bar chart that looks like this:
The x-axis labels are hard to read because there is just about no padding between them.
Here is the same chart produced by Chart.js v1.0.2:
The labels are easier to read because they are rotated more to give more padding.
Is the v2.1.4 behaviour expected? How can I have the labels rotated more so they are easier to read?
I tried adding 15° rotation to the labels like this:
This worked but of course it always adds extra rotation so it looks silly on a chart with only a few bars where the labels don't need to be rotated at all.
Many thanks!
The text was updated successfully, but these errors were encountered: