Skip to main content
100%

Fork of React + D3 Viz Starter

✓ Published0🌍 Public
WWittawat Sadindum
Last edited Mar 21, 2022
Created on Mar 13, 2022

This example presents a React starter template for integrating D3 visualizations within a margin-convention layout. The `VizContainer` component abstracts the SVG and group elements, optionally rendering gray background rectangles to highlight the margins. The visible visualization is a simple bar chart generated by the `barChart` function, which uses `d3.create` and `d3.selectAll` to render div elements with steelblue backgrounds sized proportionally to each data value. The app mounts via `ReactDOM.render`, and the code relies on CDN-loaded React 16 and D3 v6.

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