Skip to main content
100%

HindSight: Zoomable Treemap Bar Chart

✓ Published0🌍 Public
AAjayyy
Last edited Jun 16, 2019
Created on Jun 16, 2019

This interactive treemap bar chart visualizes United States trade balances across countries and continents from 1995 onward, with imports and exports shown as grouped bars per year. Users can click a country to zoom into its trade details, and a checkbox toggles between raw values and inflation-adjusted figures. Built with D3 v4, the visualization uses SVG rendering with smooth transitions (`d3.transition`) to animate the layout changes. The data is loaded from a local `data.json` file containing census trade statistics.

AI-generated description

Applying HindSight to...

Block-a-Day #12. Update of Treemap Bar Chart to enable zooming into a specific country on click.

Data Sources: Census

What I Learned: In a bit of treemap implementation trivia, nodes without a parent value of zero (i.e. those in a different continent than the selected country) will have NaN for their position values, as a result of a divide by zero, while those with a parent value but no value of their own will have position values, although width and height of, obviously, zero. I was originally just catching the NaNs, but this resulted in nodes flying to two different positions, thus the checking of d.value to determine how to position the nodes.

What I'd Do With More Time: Might be interesting if the transition was to vertically expand and fade the non-selected countries, to reinforce the idea of zooming in.

Block-a-Day

Just what it sounds like. For fifteen days, I will make a D3.js v4 block every single day. Rules:

  1. Ideas over implementation. Do something novel, don't sweat the details.
  2. No more than two hours can be spent on coding (give or take).
  3. Every. Single. Day.

Previously

forked from <a href='http://bl.ocks.org/timelyportfolio/'>timelyportfolio</a>'s block: <a href='http://bl.ocks.org/timelyportfolio/86b67adad02ea8ab8845abeedaa269cb'>Zoomable Treemap Bar Chart</a>

forked from <a href='http://bl.ocks.org/evanpeck/'>evanpeck</a>'s block: <a href='http://bl.ocks.org/evanpeck/43bd75f612fc3087d6b7a102cc196528'>HindSight: Zoomable Treemap Bar Chart</a>

forked from <a href='http://bl.ocks.org/evanpeck/'>evanpeck</a>'s block: <a href='http://bl.ocks.org/evanpeck/767ec5e067e0f9801e13ab9481b910e0'>HindSight: Zoomable Treemap Bar Chart</a>

forked from <a href='http://bl.ocks.org/lorenzopub/'>lorenzopub</a>'s block: <a href='http://bl.ocks.org/lorenzopub/69a10a4678c005d6b4c1c0e09967569a'>HindSight: Zoomable Treemap Bar Chart</a>

mit Licensed

Similar vizzes