Viewing a saved revision (read-only)
KArABDcUhGKXitXO3Ez-N
Binary Tree Circle Packing
A recursive binary tree visualized with D3 circle packing inside a responsive React component.
App.jsxgenerates a tree with three levels below its root and two children per internal node.viz.jsis the D3 rendering entry point.renderCircles.jscomputes a D3 hierarchy and pack layout, then renders nested SVG circles.useContainerDimensions.jstracks the available space.
Change the depth or branching arguments to generateTree in App.jsx to explore other tree structures. Each leaf receives a random weight between 1 and 10 when the tree is generated. D3 packs the leaves proportionally by area, with enclosing circles sized by the layout. Weights stay fixed during panning, zooming, selection, and resizing. Click a circle to highlight its outline. Drag to pan, scroll or pinch to zoom, and double-click to zoom in. Zoom ranges from 0.5× to 32× and is preserved when selecting a circle.