Skip to main content
100%

Fork of React + D3 Viz Starter

✓ Published0🌍 Public
KKenji / ケンジ
Last edited Mar 19, 2021
Created on Mar 18, 2021

This example renders a simple, smiley face composed of SVG shapes using React components and D3’s arc generator. A yellow background circle, two black eyes, and a curved mouth are centered within a fixed 960×500 viewport, with dimensions passed as props. The code imports `arc` from `d3` to compute the mouth path, while React handles component composition and state-free rendering. The face is drawn declaratively through reusable components like `BackgroundCircle`, `Eyes`, and `Mouth`, all nested inside a `FaceContainer` that applies a translation transform.

AI-generated description

Boilerplate code for a React + D3 visualization with:

  • CDN links for React, ReactDOM, and D3
  • Basic React boilerplate
  • Variables for dimensions and margins
  • A VizContainer component that:
    • Abstracts SVG/group container elements
    • Follows the margin convention
    • Show the margins, which can be easily removed by deleting the showMargins={true} prop
MIT Licensed

Similar vizzes