Skip to main content
100%

d3-indented-tree API example #15

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

This example demonstrates how the d3-indented-tree API customizes link labels and node images in a hierarchical tree layout. It shows a link label derived from the string column *color*, displayed in the middle of the link with margins, while node images use a file with custom width, height, and background to handle transparency. The code sets link width based on the numeric *weight* column, mapping values to a range of 150–300, and increases link height to 50 pixels. It uses d3.v6 and the d3-indented-tree library, reading data from an `<aside>` element and updating link width dynamically after two seconds.

AI-generated description

API examples for d3-indented-tree


myChart.linkLabel() - 4

This example shows how to

  • set the link label based on the column color of type string
  • display the label above the link
  • place the link labels in the center of the link (align: "middle")
  • set the margins
  • use a file as the node image
  • set the width and height of the node image
  • draw an empty rectangle before drawing the image (setBackground: true) (to account for transparency of the image which would show otherwise the continuation of the link in the background)
  • determine the link width based on the column weight and mapping the width based the weight values onto the intervall [150, 300]
  • changing the link height to 50 pixels
  • setting the padding of the node label to 20 pixels such that the label is not overlapping the node image

Acknowledgements:

mit Licensed

Similar vizzes