The Margin Convention
✓ Published1🌍 Public
This example demonstrates the fundamental D3 margin convention by rendering a horizontal bar chart of the top 10 most populous countries from a UN population dataset. The visualization shows population values as proportional bars within an SVG, with the chart’s plotting area properly inset from the SVG edges using a margin object. Built with React and D3 v6, the code uses `d3.csv` for data loading, `scaleBand` for the categorical y-axis, and `scaleLinear` for the quantitative x-axis. A `<g>` element is translated by the margin offsets to position all rectangles correctly.
AI-generated descriptionA program that loads in some data and creates a bar chart with margins but no info text.
MIT Licensed