Replies: 1 comment
-
Manually removing the horizontal padding in the afterFit callback does work for this:
The only problem with this is that now any really long labels at the left of the chart will simply be cutoff. So, you would have to manually calculate the padding on the left of the chart. In order to determine whether the labels actually need to be rotated I'm letting the entire chart be drawn and then looking at the label widths vs scale widths to determine if the labels should be rotated, then the chart must be redrawn with rotated labels. This is what is used to detect whether there is at least one label in need of rotation.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create a customized clustered/grouped bar chart where the bars all share the same width, but the groups occupy varying widths. This is basically the same as using the "skipNull" option, except for I'm varying the group widths instead of making the bars extra wide for groups with only a few non-null bars.
I've almost done exactly what I need by having ChartJS make a standard bar chart with the flattened data and then creating an array of stacked x-axes to simulate the groups. However, varying the rotation on the x-axis labels causes a lot of padding to be added to the left of the chart. Only a label rotation of 90 eliminates the extra padding.
I have a JSFiddle of the problem. Adjust the min/maxRotation from 0 to 30 to 90 to see the padding on the left change. How do I eliminate all the padding from the left side regardless of the rotation of the labels?
And this is a complete code chunk of that fiddle:
Beta Was this translation helpful? Give feedback.
All reactions