Skip to main content
100%

Axes with React & D3

✓ Published1🌍 Public
Rrvdv
Last edited Dec 22, 2021
Created on Dec 22, 2021

This example shows a horizontal bar chart of the top 20 countries by 2020 population, with custom axes rendered as React components. The code uses D3's `csv` loader to fetch UN population data, `scaleBand` for the categorical y-axis, and `scaleLinear` for the numeric x-axis. Instead of D3's axis generator, it manually maps over `xScale.ticks()` and `yScale.domain()` to produce SVG `<line>` and `<text>` elements for tick marks and labels. The visualization is built with React 17 and D3 v7, rendering SVGs directly in the DOM.

AI-generated description
MIT Licensed

Similar vizzes