Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Margin and Axes

Public visualization

Margin and Axes

0 stars1🌍 Public
Sshresthabhi
Last edited Oct 18, 2021
Created on Oct 18, 2021

This example shows a horizontal bar chart of population data for ten countries, drawn as an SVG with margins that create space for a left axis and bottom axis. The chart uses React to render the visualization, with D3 v5 providing the scales: a `scaleBand` for the categorical country axis and a `scaleLinear` for the population values. The data is loaded via `d3.csv` from a remote gist, and the custom `AxisBottom`, `AxisLeft`, and `Marks` components generate the tick labels and rectangular bars. The final layout applies `transform` translations to position the axes within the defined margin area.

AI-generated description

React Starter code.

Comments

Sign in to join the discussion.

MIT Licensed