Margin Convention
✓ Published1🌍 Public
This example demonstrates the margin convention for D3 visualizations by rendering a horizontal bar chart of United Nations population data. The chart displays the top 10 countries by 2020 population, with bars scaled linearly along the x-axis and categorically arranged along the y-axis. Using React hooks to manage state, the code loads CSV data with `d3.csv` and creates scales with `scaleBand` and `scaleLinear`. The SVG output groups all rectangles inside a translated `<g>` element, applying the specified margins to position the chart within the 960×500 viewport.
AI-generated descriptionA program that loads population data with D3 utilities and uses React to render the data as a bar chart.
MIT Licensed