Skip to main content
100%

D3 + React + useData

✓ Published0🌍 Public
MMinwoo Pak
Last edited Aug 10, 2021
Created on Aug 10, 2021

This example demonstrates how to build a D3.js visualization within a React application using a custom `useData` hook to load CSV data from a GitHub gist. It shows a set of circles whose count and size are dynamically controlled by input fields. The code combines React's `useRef`, `useState`, `useMemo`, and `useCallback` with D3's `select` API for incremental updates, and uses a `VizContainer` component to structure the SVG with margin conventions.

AI-generated description

Boilerplate code for a React + D3 visualization with:

  • Example of D3 as React Component
  • CDN links for React, ReactDOM, and D3
  • Basic React boilerplate
  • Variables for width, height and margins
  • useData hook to fetch a CSV URL.
  • VizContainer component that:
    • Abstracts SVG/group container elements
    • Follows the margin convention
MIT Licensed

Similar vizzes