Skip to main content
100%

Collapsible tree diagram in v4

✓ Published0🌍 Public
SSokrates86
Last edited Oct 25, 2016
Created on Oct 25, 2016

This collapsible tree diagram displays hierarchical data with a root node and multiple nested levels of children. Users can click any parent node to collapse its subtree onto itself, and click again to expand it. The visualization uses D3.js v4, leveraging the `d3.tree()` layout and `d3.hierarchy()` functions, with SVG rendering and animated transitions. The tree’s nodes and links are styled with white circles and gray paths, driven by the `update()` function that recalculates positions after each collapse or expansion.

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 v4.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 v4.

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

forked from <a href='http://bl.ocks.org/d3noob/'>d3noob</a>'s block: <a href='http://bl.ocks.org/d3noob/43a860bc0024792f8803bba8ca0d5ecd'>Collapsible tree diagram in v4</a>

mit Licensed

Similar vizzes