🌍 Public
Viewing a saved revision (read-only)
2c0e2147ae1a40dcb0e9b1f18a55becc
The Margin Convention
This example demonstrates the margin convention in D3 by rendering a horizontal bar chart of the ten most populous countries from a UN population dataset. The chart uses React to manage state and render SVG elements, with D3’s scaleBand and scaleLinear used to map country names and population values to pixel coordinates. A `<g>` element translates the chart by the specified margins, ensuring the bars are positioned within the allotted inner dimensions. The data is loaded asynchronously via `d3.csv`.
AI-generated descriptionUses React to render data