Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

The Margin convention

Public visualization

Viewing a saved revision (read-only)

021f3611898544c4a78a50be5ea00723

The Margin convention

0 stars1🌍 Public
Bbassra
Last edited Jan 12, 2023
Created on Jan 12, 2023

This example demonstrates the margin convention in D3.js by rendering a bar chart of United Nations population data for 2019, showing the top 10 countries. The visualization uses React components with D3 scales (d3.scaleBand and d3.scaleLinear) to map countries to the y-axis and population values to the x-axis. An SVG group element applies the margin offsets via a transform, separating the plotting area from the axes. The code fetches the CSV data using d3.csv and renders grid lines, tick labels, and horizontal bars within the defined inner dimensions.

AI-generated description

A Pathatic bar chart with React & d3.