The Margin Convention
✓ Published1🌍 Public
This example demonstrates the margin convention for bar charts, displaying the top 10 countries by 2020 population from a UN dataset. The chart renders horizontal bars using SVG `<rect>` elements, positioned with `d3.scaleBand` for the categorical y-axis and `d3.scaleLinear` for the quantitative x-axis. Data loads asynchronously via `d3.csv` into React state with `useEffect`, while margins are applied through a translated `<g>` group. The visualization shows how to separate chart dimensions from overall SVG size using explicit margin objects.
AI-generated descriptionA program thtat loads in some data using D3 utilities, and uses React state to keep track of the data.
MIT Licensed