The Margin Convention
✓ Published1🌍 Public
This example demonstrates the margin convention in a bar chart, showing population data for the top 10 countries from the UN Population 2019 dataset. A `<g>` element is translated by the margin values, with the inner plotting area calculated separately for the x and y scales. It uses React with `useState` and `useEffect` to load data via `d3.csv`, then renders SVG rectangles positioned by `d3.scaleBand` and `d3.scaleLinear` on an SVG canvas. The chart displays horizontal bars without axes or labels, focusing on the layout offset technique.
AI-generated descriptionAdding margin to the bar chart using the margin convention.
MIT Licensed