Skip to main content
100%

Making a Bar Chart with React & D3

✓ Published1🌍 Public
JJanet Li
Last edited Aug 14, 2021
Created on Aug 14, 2021

This example shows a horizontal bar chart of the top 10 most populous countries in 2020, rendered as SVG rectangles. React manages the loading state and data via `useState` and `useEffect`, while D3 utilities handle data fetching with `d3.csv`, quantitative scaling with `scaleLinear`, and categorical positioning with `scaleBand`. The chart updates once the CSV data from a GitHub gist is loaded, mapping each country’s population to a rectangle width in a fixed 960×500 viewport.

AI-generated description

A program that loads in some data about CSS named colors using D3 utilities, and uses React state to keep track of the data.

MIT Licensed

Similar vizzes