Skip to main content
100%

Margin Convention

✓ Published1🌍 Public
Rrajamrit-singh
Last edited Jan 31, 2023
Created on Jan 31, 2023
Forked from Bar chart

This example demonstrates the D3 margin convention, a common pattern for reserving space around a chart’s plotting area. It loads UN population data from a CSV file and renders horizontal bars for the top 10 countries, with bar widths proportional to their 2020 population. The React app uses `useState` and `useEffect` to fetch and parse the data with `d3.csv`, then constructs SVG rectangles using `scaleBand` for the y-axis and `scaleLinear` for the x-axis. A margin object defines offsets, and a `<g>` transform aligns the chart within the SVG.

AI-generated description

A program that loads in some data

MIT Licensed

Similar vizzes