🌍 Public
Viewing a saved revision (read-only)
f9b53d6586c94ef5b373d2bec01b0bbb
Making a Bar Chart with React & D3
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 descriptionA program that loads in some data about CSS named colors using D3 utilities, and uses React state to keep track of the data.