🌍 Public
Viewing a saved revision (read-only)
0d64fd91dd6a4586afe4849209bec6b3
The Margin Convention
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 description