Skip to main content
100%

Making a Bar Chart with React & D3

✓ Published1🌍 Public
PPhronesis
Last edited Nov 16, 2021
Created on Nov 16, 2021

This example shows a horizontal bar chart of UN population data for the top 10 countries, rendered as SVG rectangles with randomly assigned colors. The React component uses the `useState` and `useEffect` hooks to load and store data fetched via `d3.csv`, while `d3.scaleBand` and `d3.scaleLinear` map countries and population values to screen coordinates. The chart displays loading text before the data arrives, then maps each row to a `<rect>` element with dimensions derived from the scales.

AI-generated description

Using React & D3 to render a bar chart of UN population data.

MIT Licensed

Similar vizzes