Skip to main content
100%

Axes with React & D3

✓ Published1🌍 Public
TTaeyoung Ahn
Last edited Sep 13, 2021
Created on Sep 11, 2021

This example visualizes the top ten most populous countries in 2020 using a horizontal bar chart, rendered as SVG. The code combines D3 v7 utilities—`csv`, `scaleBand`, `scaleLinear`, and `max`—to fetch and scale the data, while React’s `useState` and `useEffect` manage the asynchronous loading and component state. Axes are constructed manually with D3’s tick values and React’s JSX, drawing grid lines, tick labels, and bars within a translated `<g>` element. The chart updates entirely through React rendering, with no D3 selection or transition APIs involved.

AI-generated description

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

MIT Licensed

Similar vizzes