🌍 Public
Viewing a saved revision (read-only)
ce51d29b00314c78ac1c38c7d089725d
The Margin convention
This example demonstrates the margin convention in D3.js by rendering a bar chart of United Nations population data for 2019, showing the top 10 countries. The visualization uses React components with D3 scales (d3.scaleBand and d3.scaleLinear) to map countries to the y-axis and population values to the x-axis. An SVG group element applies the margin offsets via a transform, separating the plotting area from the axes. The code fetches the CSV data using d3.csv and renders grid lines, tick labels, and horizontal bars within the defined inner dimensions.
AI-generated descriptionA Pathatic bar chart with React & d3.