Grouped chart with offset, but center if only one group #9452
-
Hi - I'm looking to make a grouped bar chart however when there are fewer than the max number of groups, I'd like to center those bars. For example (assuming the data in the grouped bar chart example), if category B had only data from group x, then I would like the blue bar to be centered at the x-axis marker for category B (where the bar for y is in the example). I'd also like the bar width to be the same. Any advice on how to accomplish this? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Jon, I think there are two ways to achieve this, one isn't quite a grouped bar chart but doesn't need manual bar sizes and the other is a grouped bar chart but requires manual sizing of the bar. The first approach is to use a column encoding of an x encoding like this, which produces this chart: For the second we can use a series of transforms to generate manual xOffsets like this, which produces this chart: -Kyle |
Beta Was this translation helpful? Give feedback.
Hi Jon,
I think there are two ways to achieve this, one isn't quite a grouped bar chart but doesn't need manual bar sizes and the other is a grouped bar chart but requires manual sizing of the bar.
The first approach is to use a column encoding of an x encoding like this, which produces this chart:
For the second we can use a series of transforms to generate manual xOffsets like this, which produces this chart:
-Kyle