Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

United Nations Bar Chart (Axis with React and D3)

Public visualization

United Nations Bar Chart (Axis with React and D3)

0 stars2🌍 Public
RRichardPearce60
Last edited Feb 13, 2022
Created on Jan 30, 2022

This example shows a horizontal bar chart of the top 10 most populous countries in 2019, with countries on the y-axis and population on the x-axis. The React component loads CSV data via `d3.csv`, transforms the population column with a row function, and stores it using `useState` and `useEffect`. Scales from `d3.scaleBand` and `d3.scaleLinear` position the bars, while `xScale.ticks()` generates gridlines and tick labels in the SVG. React renders the rects, lines, and text elements directly, with axes drawn manually rather than through D3 axis helpers.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed