Skip to main content
100%

React + D3 Viz Starter

✓ Published1🌍 Public
MMark Lam
Last edited Dec 28, 2021
Created on Dec 28, 2021

This example presents a minimal React and D3.js starter template for building SVG data visualizations. It defines a reusable `VizContainer` component that manages an SVG canvas with configurable dimensions and margins, following the standard margin convention for chart layouts. The component optionally renders background rectangles to visually indicate the plot area and outer canvas. The code imports React, ReactDOM, and D3 v6 via CDN, and the main `App` function constructs a single `VizContainer` with a fixed 960×500 pixel size and equal 30-pixel margins.

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