Skip to main content
100%

The Margin Convention

✓ Published1🌍 Public
GGabriel Dias Menezes
Last edited May 30, 2022
Created on May 30, 2022
Forked from React D3 Bar Chart

This example demonstrates the margin convention for bar charts, displaying the top 10 countries by 2020 population from a UN dataset. The chart renders horizontal bars using SVG `<rect>` elements, positioned with `d3.scaleBand` for the categorical y-axis and `d3.scaleLinear` for the quantitative x-axis. Data loads asynchronously via `d3.csv` into React state with `useEffect`, while margins are applied through a translated `<g>` group. The visualization shows how to separate chart dimensions from overall SVG size using explicit margin objects.

AI-generated description

A program thtat loads in some data using D3 utilities, and uses React state to keep track of the data.

MIT Licensed

Similar vizzes