Skip to main content
100%

Axes with React & D3

✓ Published1🌍 Public
LLewis Ward
Last edited Aug 1, 2021
Created on Jun 27, 2021

This example shows a horizontal bar chart of the top 15 countries by 2020 population, with axes drawn manually using SVG elements. React state loads the CSV data via `d3.csv`, while `d3.scaleBand` and `d3.scaleLinear` map countries and population values to pixel coordinates. The x-axis ticks are generated with `xScale.ticks()` and rendered as lines with labels, and the y-axis labels align with each bar’s midpoint. All marks and axes are SVG elements produced declaratively in JSX.

AI-generated description

A program that loads in some data using D3 utilities, and uses React state to keep track of the data.

MIT Licensed

Similar vizzes