🌍 Public
Viewing a saved revision (read-only)
021f3611898544c4a78a50be5ea00723
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.