Skip to main content
100%

Collapsible tree diagram in v6

✓ Published0🌍 Public
Dd3noob
Last edited Jun 19, 2021
Created on Sep 13, 2020

This interactive collapsible tree diagram displays hierarchical data with clickable parent nodes that expand and collapse their child branches. Built with D3 v6, it uses `d3.hierarchy` and `d3.tree` to compute node positions, with SVG circles and text labels rendering the structure. Clicking a node triggers a smooth 750ms transition that animates nodes and diagonal link paths to their new positions, while collapsed nodes are indicated by a lightsteelblue fill and pointer cursor. The example is derived from Mike Bostock’s original collapsible tree and demonstrates node enter, update, and exit patterns with animated transitions.

AI-generated description

This is a d3.js tree diagram that incldes an interactive element as used as an example in the book D3 Tips and Tricks v6.x.

Any parent node can be clicked on to collapse the portion of the tree below it, on itself. Conversly, it can be clicked on again to regrow.

It is derived from the Mike Bostock Collapsible tree example and updated to use v6.

Kudos and thanks also go out to Soumya Ranjan for steering me in the fight direction for the diagonal solution.

mit Licensed

Similar vizzes