Skip to main content
100%

The Margin Convention

✓ Published1🌍 Public
TTsaikkari
Last edited Aug 1, 2021
Created on Aug 1, 2021
Forked from Pathetic bar chart

This example demonstrates the Margin Convention, a fundamental layout pattern for D3 visualizations, using a horizontal bar chart of the ten most populous countries in 2020. The chart loads UN population data via `d3.csv`, then renders SVG rectangles with React components. The visualization shows how margins create an inner plotting area, with `d3.scaleBand` mapping country names to the y-axis and `d3.scaleLinear` scaling population values to the x-axis. The code explicitly calculates `innerHeight` and `innerWidth` by subtracting margins from the total dimensions, and applies the margin offset through an SVG `<g>` transform.

AI-generated description

A program that loads in some data about countries population using D3 bar chart, and uses React to render the data.

MIT Licensed

Similar vizzes