Skip to main content
100%

United Nations Bar Chart (Axis with React and D3)

✓ Published2🌍 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
MIT Licensed

Similar vizzes