Collapsing the Stacks of Bars into Groups

Three actions will be taking place in this example. Stacked bar chart will be created, followed by creating the grouped bar chart and then transitioning between the two type of chart. There will be many interlocking components.Thinking of extending this example to include Histograms of the categories...

Transition has start and the end states, and a trigger that initiates it

The transition itself has not meaning without the starting and the ending. The code has to tell that state.One issue I faced was using the "this.parentNode" with arrow function "=>" doesn't work.

Why the chart go above the frame?

Because the "y" attribute gets set to 0 or undefined value. In the svg the 0 is at the top of the page. When the scales are computing these values, such issues always occur. Especially when you type the code.

Why color scheme schemeCategory20c is considered as null?

D3 library is continuously updated, so the recent ver 7.0 doesnt have this color scheme. In its place, many other other color schemes like schemeSet1, schemePaired, schemeAccent have been introduced. I have chosen the schemeTableau10 for this visualisation.

What to do when the visuals don't appear

Debug by opening the Developer tools, and checking the elements.By looking at the elements, the kind of error can be easily understood. If there is no elements at all, then probably you did not include the .data(yourData) command in the selectAll method.