Skip to main content
100%

D3 and React Hooks

✓ Published3🌍 Public
Ggjonor
Last edited Feb 1, 2020
Created on Jan 29, 2020
Forked from React Starter

Two pie charts render identical datasets side by side, each taking a different approach to integrating D3 with React function components. The first, PieSVG, lets React fully manage the SVG lifecycle, mapping data arcs to JSX elements. The second, PieHooks, uses `useEffect` and `useRef` to imperatively manipulate the DOM with D3 selections like `selectAll`, `enter`, and `merge`. Both use `d3.pie`, `d3.arc`, and `d3.scaleOrdinal` to generate and style the arcs, with random data regenerated on button click.

AI-generated description
MIT Licensed

Similar vizzes