ErikGartner / dTree

A library for visualizing data trees with multiple parents, such as family trees. Built on top of D3.
https://treehouse.gartner.io/ErikGartner/58e58be650453b6d49d7
MIT License
521 stars 139 forks source link

How do you use the nodeSize callback? #55

Closed lipedeitos closed 7 years ago

lipedeitos commented 7 years ago

Hi Erik!

Sorry to bother you again. I'm trying to use the nodeSize function following the documentation but its not working, probably i'm doing something wrong.

nodeSize: function(nodes, width, textRenderer){ return [120,70]; }, Using this, console prints "Error: attribute x: Expected length, "NaNpx"." What i'm doing wrong?

Cheers.

ErikGartner commented 7 years ago

Hi @lipedeitos!

It was a while since I've used it but, from what I remember you need to also set the nodes width and height. Here's a snippet from the default function in Builder.js.

      n.cHeight = height;
      if (n.data.hidden) {
        n.cWidth = 0;
      } else {
        n.cWidth = width;
      }

Then you return the maximum of width and height.

/Erik

Lightislands commented 5 years ago

Hi Erik!

Could you please provide with an example of nodeSize callback function to set width and height for each or all nodes?