Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Ep21 Bar Chart with React/D3

Public visualization

Ep21 Bar Chart with React/D3

0 stars1🌍 Public
GGordon Yang
Last edited Apr 8, 2021
Created on Apr 7, 2021

This example displays a horizontal bar chart of the top ten countries by projected 2020 population, sourced from a UN population dataset (CSV). Built with React and D3 v6, the app fetches data via `d3.csv`, sorts it, and renders SVG `<rect>` elements. It uses `scaleBand` for the y-axis countries and `scaleLinear` for the x-axis population values, with bar widths mapped to population counts and heights set by the band’s `bandwidth`. React’s `useState` and `useEffect` handle data loading, while `ReactDOM.render` mounts the chart into the root div.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.

Comments

Sign in to join the discussion.

MIT Licensed