Skip to content

How to create stacked grouped bar chart with visx? #1732

Answered by tkdgus96
codesfromshad asked this question in Q&A
Discussion options

You must be logged in to vote

The first step of doing this is to make the data friendly to this chart. I made the data like this
[ [first data group], [second data group], [third data group] ]

The trick is to control the width by the length of your data. For example, if we want to visualize 3 groups of stacked bars, simply divide the width of each bar by 3 and multiply some constant between 0 and 1 (since bars need space from each other). Then, we need to control the X position. Loop the total data and subtract or add a multiple of the bar width to the X position depending on the group's index.

Here is a sandbox link demonstrating how you can create a stacked group bar chart with visx.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@codesfromshad
Comment options

Answer selected by codesfromshad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants