The Margin Convention
✓ Published1🌍 Public
This example demonstrates the importance of chart margins by rendering the top 10 most populous countries as a pathetic bar chart with no axes. The bars are drawn directly against the SVG edges, making the lack of scales and labels immediately apparent. The code uses React hooks to load data from the United Nations World Population Prospects 2019 via `d3.csv`, then maps that data with `d3.scaleBand` and `d3.scaleLinear` to position rectangles. A `<g>` transform applies the margin offsets, while `d3.max` computes the domain for the x-axis scale.
AI-generated descriptionA program that shows the top 10 most populous countries as a pathetic bar chart with no axes.
MIT Licensed