Collapsible Tree Example
This example shows a collapsible tree diagram where each node is represented by a symbol whose shape depends on the node’s value: values greater than or equal to nine appear as crosses, while smaller values appear as diamonds. The tree layout is generated with `d3.layout.tree`, and node paths are drawn using `d3.svg.symbol` with a custom type function. Links are rendered as diagonal paths via `d3.svg.diagonal`, with stroke colors derived from each target node’s “level” property. The visualization uses SVG and is based on a static JSON dataset, with a white fill and black stroke for all symbols.
AI-generated descriptionThis is an example of a tree digram where the nodes can be varied amongst the (range of symbols)[https://github.com/mbostock/d3/wiki/SVG-Shapes#symbol] available via the d3.svg.symbol command.
Many thanks to Josiah who asked the question of how this could be done.
There are of course several different methods. A separate custom svg path could be declared and used or a more elegant and extensible method might be to apply the symbol type depending on the range of input values (as is used in Mike Bostock's Force-directed Symbols.
It is used as an example and described in the book D3 Tips and Tricks.