Skip to main content
100%

Loading Data with React and D3 (attempt 2)

✓ Published1🌍 Public
HHeidi Stockton
Last edited Apr 22, 2021
Created on Apr 21, 2021

This example demonstrates how to load a CSV dataset of named CSS colors and render each color as a small rectangle using React components. The code uses D3’s `csv` utility to fetch and parse the data from a GitHub gist, then stores it in React state via the `useState` and `useEffect` hooks. Once loaded, the `data.map` function generates one div per color with its background set to the `RGB hex value` column. A loading message appears until the asynchronous data fetch completes.

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