Skip to main content
100%

The Margin Convention

✓ Published1🌍 Public
RRajat Dangat
Last edited Mar 26, 2021
Created on Mar 26, 2021
Forked from Pathetic Bar Chart

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 description

Adding margin to the bar chart using the margin convention.

MIT Licensed

Similar vizzes