react-d3-tree icon indicating copy to clipboard operation
react-d3-tree copied to clipboard

Setting initial collapsed state of nodes

Open paulfedory opened this issue 3 years ago • 15 comments

Are you reporting a bug, or opening a feature request?

Question or Feature Request

What is the behavior/output you expect?

How do you set the initial collapsed/expanded state of any particular set of nodes in the Tree data? In v1, we were able to do this via the _collapsed attribute - but setting the __rd3t.collapsed attribute does not have the same effect.

What version of react-d3-tree are you using?

3.3

paulfedory avatar Jul 15 '22 21:07 paulfedory

If anyone knows of any workarounds to this, e.g. via an imperative API call, please do let me know. 💜

sockthedev avatar Feb 08 '23 14:02 sockthedev

Copying across the example I posted of what I am trying to achieve;

I would like to load the tree with a specific path expanded (everything else collapsed).

For example, given the following tree;

             A
           /   \
          /     \
         B       E
        / \
       /   \
      C     D

I would like to be able to set the path of A -> B -> D to be be visible/expanded when the tree initially loads;

             A
           /   
          /     
         B 
          \
           \
            D

sockthedev avatar Feb 09 '23 06:02 sockthedev

hey, @sockthedev. Is there any chance that you resolved the issue? I'd highly appreciate if you reply. Ciao

hikmert avatar Apr 14 '23 11:04 hikmert

Hey @hikmert, in the end I rendered the entire tree, but then updated the style for the active path so that it was "brighter" than the rest of the nodes. I would have preferred the above, but for now this is working. I'll see how the solution scales though.

sockthedev avatar Apr 17 '23 12:04 sockthedev

Hey, @sockthedev. Were you able to resolve the issue? I basically had search kind of thing built on this. So, Stuck with using v1.

Bishtman12 avatar Jun 19 '23 03:06 Bishtman12