Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Making a Bar Chart with React & D3

Public visualization

Viewing a saved revision (read-only)

68e83025345a4977aadead094766730c

Making a Bar Chart with React & D3

0 stars1🌍 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.