Skip to main content
100%

Stacked-to-Grouped | JSON Data, Horizontal Bars, String Series Names

✓ Published0🌍 Public
TThanaporn-sk
Last edited Mar 4, 2017
Created on Mar 4, 2017

This example demonstrates a horizontal bar chart that toggles between stacked and grouped layouts using animated transitions. The visualization loads JSON data with string series names and renders bars with D3 v4, using SVG and custom radio buttons for user interaction. The animation preserves object constancy through sequenced transitions, first adjusting bar heights then widths, based on the design principles of Heer and Robertson. The code implements the D3 stack function, scaleBand, scaleLinear, and transition methods to smoothly morph between the two representations.

AI-generated description

switch between stacked and grouped layouts using sequenced transitions ✨

animations preserve object constancy and allow the user to follow the data across views

animation design by Heer and Robertson inspired by Byron and Wattenberg

this iteration draws horizontal bars from static data that have strings for the series names

an ES2015 implementation in something like the airbnb style

inspired by Stacked-to-Grouped Bars from @mbostock

custom radio buttons from the codepen Pure CSS & HTML cross-browser elegant Radio Buttons from knitevision1

you can also view this set of experiments in github repo form

👏 to @alexmacy for wading through a few thousand transition errors to help me find the data-prep 🐛 causing them all

Stacked-to-Grouped | Generated Data, Vertical Bars
Stacked-to-Grouped | JSON Data, Vertical Bars
Stacked-to-Grouped | Generated Data, Horizontal Bars
Stacked-to-Grouped | JSON Data, Horizontal Bars
Stacked-to-Grouped | JSON Data, Horizontal Bars, String Series Names

forked from <a href='http://bl.ocks.org/micahstubbs/'>micahstubbs</a>'s block: <a href='http://bl.ocks.org/micahstubbs/02f882c439e931c50e26be8dc403a775'>Stacked-to-Grouped | JSON Data, Horizontal Bars, String Series Names</a>

forked from <a href='http://bl.ocks.org/anonymous/'>anonymous</a>'s block: <a href='http://bl.ocks.org/anonymous/5c9f6b7805c405aeeb48598e9c97ef4a'>Stacked-to-Grouped | JSON Data, Horizontal Bars, String Series Names</a>

forked from <a href='http://bl.ocks.org/anonymous/'>anonymous</a>'s block: <a href='http://bl.ocks.org/anonymous/55bce7e1b00a751a888d19237f8941c6'>Stacked-to-Grouped | JSON Data, Horizontal Bars, String Series Names</a>

mit Licensed

Similar vizzes