Skip to main content
100%

d3-indented-tree API example #14

✓ Published0🌍 Public
EEE2dev
Last edited Dec 30, 2020
Created on Jul 25, 2019

This example demonstrates how to dynamically color tree links based on a data column using the d3-indented-tree API. It assigns colors to link paths according to the `name` field, with a custom ordinal scale mapping categories like `flare` and `graph` to distinct hues while defaulting unknown values to lightgrey. The visualization loads hierarchical data from a remote JSON file (flare.json) and renders an indented tree with adjustable link strength. The code uses d3.v6, d3-indented-tree, and a `linkColor("name", {scale: colorScale})` configuration, later modifying link width via `linkWidth()`. The chart is appended to the body and rendered through a helper function.

AI-generated description

API examples for d3-indented-tree


myChart.linkColor() - 2

This example shows how to set the color of the links based on values of the column name with myChart.linkColor(). A color scale is defined to map the values to colors. The column name is passed as the first attribute. The second attribute ist an options object where the scale property is set.


Acknowledgements:

mit Licensed

Similar vizzes