-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Misplaced first label in horizontal bar chart, visible mostly when chart height is small #1266
Comments
I think that the problem is in the axis.js file. The code is currently this (line 48 onwards): // TODO: Find better solution for solving this problem
// Calculate how much space we have available for the label
var labelLength;
if(projectedValues[index + 1]) {
// If we still have one label ahead, we can calculate the distance to the next tick / label
labelLength = projectedValues[index + 1] - projectedValue;
} else {
// If we don't have a label ahead and we have only two labels in total, we just take the remaining distance to
// on the whole axis length. We limit that to a minimum of 30 pixel, so that labels close to the border will
// still be visible inside of the chart padding.
labelLength = Math.max(this.axisLength - projectedValue, 30);
} As you can see, there's a hard-coded '30', which is causing an issue when the spacing is actually less that 30. I think that it can be fixed by doing this (only tested on a sample of 1!): // TODO: Find better solution for solving this problem
// Calculate how much space we have available for the label
var labelLength;
if(projectedValues[index + 1]) {
// If we still have one label ahead, we can calculate the distance to the next tick / label
labelLength = projectedValues[index + 1] - projectedValue;
} else {
// If we don't have a label ahead and we have only two labels in total, we just take the remaining distance to
// on the whole axis length. We limit that to a minimum of 30 pixel, so that labels close to the border will
// still be visible inside of the chart padding.
labelLength = Math.max(this.axisLength - projectedValue, this.axisLength / this.ticks.length);
} This substitutes the hard-coded '30' with the calculated spacing. I'm not a javascript developer, so don't really want to try and do a pull request, but if anyone is still actively contributing to this project, I'd be really grateful if they could test the above, and do another release if it fixes the problem. |
Weirdly, it stops being visible when the chart height gets large.
The text was updated successfully, but these errors were encountered: