Skip to main content
Public

Share visualization

Loading preview…

Rendering CSV named colors with React

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Rendering CSV named colors with React

1
IIlgar Akalın
Last edited Oct 4, 2021
Created on Oct 4, 2021

This example visualizes the 148 CSS named colors as horizontal color bars stacked vertically, with each bar’s background color set from the CSV’s “RGB hex value” column. It demonstrates unidirectional data flow in React, loading the dataset via D3’s `csv` utility inside a `useEffect` hook and managing the async result with `useState`. The app renders a “Loading…” message until the data arrives, then maps each row to a styled `<div>` element, with mouse events available for user interaction. The code uses React 16.13.1, ReactDOM, and D3 v6.

AI-generated description

Loading CsV data in React

Includes:

  • Mouse events
  • Unidirectional Data Flow
  • The notion of "State"
  • React's useState hook

A program that loads in some data from MDN: css named colors using D3 utilities, and uses React to render the data.

Comments

Sign in to join the discussion.

MIT Licensed