org-chart icon indicating copy to clipboard operation
org-chart copied to clipboard

Bidirectional Org Chart ( Two Layouts at a time )

Open bhavyakelp opened this issue 1 year ago • 8 comments

Hi

I am wanting to create a bidirectional org chart ( similar to a family tree), which has the root node at the center, its children below it and parents above it with each node having a fixed height and width. If I further expand my parent nodes they open upwards and if I open child node they open downwards.

In the org chart example that is posted (here),

  • If the layout is bottom : It opens the chart in bottom up direction ( upwards ) Screenshot 2024-07-16 at 4 20 08 PM

  • and if the layout is top : It opens the chart in top down direction (downwards)

Screenshot 2024-07-16 at 4 20 31 PM

what I aim to do is have both of these in one single chart and create something similar to this:

  • with the yellow node being the root
  • purple being the children
  • green being the parent
  • and a expand (+)/ collapse(-) icon to toggle between expanded states

image

How will be able to achieve this ? I tried multiple ways but am unable to attain this behaviour.......

bhavyakelp avatar Jul 16 '24 11:07 bhavyakelp

Hi, it's not easily possible with this library, and not sure how to approach it at the moment

bumbeishvili avatar Jul 16 '24 13:07 bumbeishvili

@bumbeishvili are there any algorithms / packages that can help me achieve this ?

bhavyakelp avatar Jul 17 '24 05:07 bhavyakelp

No idea

bumbeishvili avatar Jul 17 '24 18:07 bumbeishvili

@bumbeishvili , no worries, and thank you for your assistance.

If I use your codebase to achieve this behavior, I understand that I need to position the parent nodes at the top. Could you please guide me on which functions I should look into to make these changes?

bhavyakelp avatar Jul 18 '24 09:07 bhavyakelp

I am guessing it will be along these lines

https://github.com/bumbeishvili/org-chart/blob/cb1f376656bc83360a4fea6872597fd427fcd775/src/d3-org-chart.js#L838-L848

bumbeishvili avatar Jul 18 '24 14:07 bumbeishvili

That helps, @bumbeishvili!

In the meantime, I was browsing through some of your projects, and I find them truly amazing! But, I came across your secureLogic visualization, which is very similar to what I need.

Screenshot 2024-07-18 at 10 22 28 PM

If you see this chart is similar to an org chart but works in two directions (LR and RL) So if I reciprocate this chart, I can then make it TB and BT, add my custom nodes and voila!

Is that a good idea and is it possible? I would like your view and input on this ......

bhavyakelp avatar Jul 18 '24 16:07 bhavyakelp

Yes, it's similar, as I remember I did it from scratch, instead of using this library, I don't exactly remember how I did it, but If I were to do it again, I'd use the same Flextree library, I'd probably just change the direction of some branches from positive to negative coordinates

https://observablehq.com/@bumbeishvili/horizontal-collapsible-d3-flextree

bumbeishvili avatar Jul 18 '24 17:07 bumbeishvili

@bumbeishvili, I was finally able to achieve the chart I wanted. Thank you for your help !

bhavyakelp avatar Jul 23 '24 09:07 bhavyakelp