Skip to main content
100%

The Margin Convention

✓ Published1🌍 Public
SSonja Ek
Last edited Jun 1, 2021
Created on Jun 1, 2021
Forked from Pathetic Bar Chart

This example demonstrates the fundamental D3 margin convention by rendering a horizontal bar chart of the top 10 most populous countries from a UN population dataset. The visualization shows population values as proportional bars within an SVG, with the chart’s plotting area properly inset from the SVG edges using a margin object. Built with React and D3 v6, the code uses `d3.csv` for data loading, `scaleBand` for the categorical y-axis, and `scaleLinear` for the quantitative x-axis. A `<g>` element is translated by the margin offsets to position all rectangles correctly.

AI-generated description

A program that loads in some data and creates a bar chart with margins but no info text.

MIT Licensed

Similar vizzes