score:1

Accepted answer

d3.heirarchy (https://github.com/d3/d3-hierarchy/blob/master/README.md#hierarchy) returns these properties for each node:

  • node.depth
  • node.parent

You could use .depth as an input to a function that determines fill opacity, eg higher depth = more opacity. You could use .parent as an input to a function that iterates up to the parent that has parent: null, and set the colour based on that node's value.


Related Query

More Query from same tag