Skip to main content
100%

The Margin convention

✓ Published1🌍 Public
DDaniel Zsido
Last edited Nov 17, 2021
Created on Nov 16, 2021
Forked from D3 piechart

This example demonstrates how D3’s margin convention works by rendering a horizontal bar chart of the top ten countries by 2020 population estimates from the UN World Population Prospects 2019 dataset. The chart uses a React component with `d3.csv` to load data, `scaleBand` for the categorical y-axis, and `scaleLinear` for the x-axis. An outer SVG with fixed width and height contains a translated group element (`g`) that positions the bars inside the margin-defined inner area, which is computed by subtracting the top, right, bottom, and left margin values from the outer dimensions.

AI-generated description
MIT Licensed

Similar vizzes