Skip to main content
100%

Tree Example

✓ Published0🌍 Public
Dd3noob
Last edited Nov 30, 2019
Created on Jan 5, 2014

This example demonstrates a collapsible tree diagram built with D3.js, visualizing hierarchical data loaded from an internal JSON array. It shows a root node ("DEF") with branches extending to children, including nested nodes and collapsed subtrees that users can expand by clicking. The code converts flat JSON records into a tree structure using array reduction and parent-child mapping, then renders it with the `d3.layout.tree` layout and `d3.svg.diagonal` paths for connecting links. Node transitions animate smoothly when toggling collapsed states.

AI-generated description

An example file to go alongside a question asked on Stack Overflow as to how to load a JSON array from an internal array rarther than import it as a file. The example here is a combination of Mike Bostocks Collapsible Tree example and a question asked on Stack Overflow on how to generate multi-level JSON formatted data.

mit Licensed

Similar vizzes