Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

The Margin convention

Public visualization

The Margin convention

0 stars1🌍 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

Comments

Sign in to join the discussion.

MIT Licensed