Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

The margin convention

Public visualization

The margin convention

0 stars0🌍 Public
Mmaxthamt
Last edited Mar 13, 2021
Created on Mar 13, 2021

This example demonstrates the D3 margin convention by rendering a horizontal bar chart of the top 10 most populous countries in 2020, using data from the UN Population 2019 dataset. The code uses React state and the `useEffect` hook to load and parse the CSV via `d3.csv`, then applies `scaleBand` and `scaleLinear` for layout. It shows how to apply margins by translating an SVG `<g>` group with `margin.top` and `margin.left`, drawing gridlines from `xScale.ticks()` and styled `<rect>` elements for each bar. Rendering relies on React’s virtual DOM and SVG output.

AI-generated description

A program that uses React to render some data about CSS named colors using D3 utilities and uses React state to keep track of the data.

Comments

Sign in to join the discussion.

MIT Licensed