🌍 Public
Viewing a saved revision (read-only)
5b27c60482c24f80ac50ab79e69fe27b
The Margin Convention
This example shows a horizontal bar chart of the top 10 countries by population in 2020, loaded from a CSV file. The chart demonstrates the margin convention by offsetting a group of rectangles using an SVG transform. React state manages the asynchronous data loading with `d3.csv`, while the scales `scaleBand` and `scaleLinear` map country names and population counts to the inner chart dimensions. The bars are rendered as SVG `rect` elements within React’s declarative JSX structure.
AI-generated descriptionLoads in some data using D3 and uses react state to track the data