🌍 Public
Viewing a saved revision (read-only)
0d178b907c8e406eb15a6d42f87e7eda
cannavis1
This example shows a D3.js pie chart built within a React application for visualizing the chemical composition of cannabis strains. It displays the percentage of each compound as a labeled slice of the pie, with the strain name shown on a button. The visualization is rendered using SVG and React function components, contrasting two approaches: one uses a React Hook to manage the D3 drawing lifecycle, while the other uses pure, non-side-effect SVG rendering. The chart uses `d3.pie()` and `d3.arc()` to compute and draw the arcs, with `d3.scaleOrdinal(d3.schemeCategory10)` for color and `d3.format('.2f')` for label formatting.
AI-generated descriptionReact Starter code.
D3 and React Hooks article