Skip to main content
100%

Axes with React & D3

✓ Published1🌍 Public
BBenoit Mouly
Last edited Sep 5, 2022
Created on Jul 29, 2022

This example displays the top 10 most populous countries as horizontal bars with D3-generated axes inside a React component. It uses `d3.csv` to load UN population data for 2020, `d3.scaleBand` for the categorical y-axis, and `d3.scaleLinear` for the continuous x-axis. The React `useState` and `useEffect` hooks manage data fetching, while manual SVG elements render the axes ticks and gridlines, with D3’s `scaleBand().ticks()` providing numeric tick values.

AI-generated description

A program that shows the top 10 most populous countries as a pathetic bar char with no axes.

MIT Licensed

Similar vizzes