Skip to main content
100%

d3-indented-tree API example #32

✓ Published0🌍 Public
EEE2dev
Last edited Dec 30, 2020
Created on Sep 21, 2019

This example demonstrates how node sorting can be re-applied in a d3-indented-tree chart. It initially renders a tree from CSV-like data embedded in an aside element, then after a two-second delay, triggers a resort using the `nodeSort` method with the `num` key, ascending order, and height-aware grouping. The code uses the d3-indented-tree API built on D3 v6, with `d3.indentedTree` initializing the chart and `linkLabel` setting the edge labels. The `convertTypes` option is set to "none," causing all columns to remain strings, which influences the lexical sorting behavior.

AI-generated description

API examples for d3-indented-tree


myChart.nodeSort() - 2

This example shows how to resort the nodes of the tree. When disabling convertTypes, the columns become strings and thus affecting the sorting order. The sorting order can be also parametrized by

  • ascending: true (default is false)
  • sortByHeight: true (default is false). Now the sorting is done for each group based on the height of the node.

The height of a node is the greatest distance from any descendant leaf.


Acknowledgements:

mit Licensed

Similar vizzes