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

Two Parent Root

Open galihprasetio opened this issue 2 years ago • 4 comments

Can create chart with two parent root on top hirarchy ?

galihprasetio avatar Apr 07 '22 03:04 galihprasetio

No

bumbeishvili avatar Apr 07 '22 07:04 bumbeishvili

Can we achieve this Fake multi-rooted tree example http://bl.ocks.org/ialarmedalien/c92a58f2fee695c3931c1b6e30540d98 here in this library @bumbeishvili ?

Ayesha-Sayyed avatar Apr 18 '22 11:04 Ayesha-Sayyed

I guess so

You can just use CSS to hide first node and first two links

image

it's just SVG

image

You will probably also need to:

  • Decrease first nodeHeight
  • Decrease the first level childrenMargin
  • Set chart.compact(false)

bumbeishvili avatar Apr 18 '22 11:04 bumbeishvili

Thanks! @bumbeishvili

Ayesha-Sayyed avatar Apr 26 '22 06:04 Ayesha-Sayyed

You can just use CSS to hide first node and first two links

@bumbeishvili It seems the order of the links is not guaranteed, though.

I have tried with the following code:

let linkCount = chart.getChartState().root.children.length;
if (linkCount > 0) {
    const wrapper = document.querySelector(".links-wrapper"); // or extract from getChartState().linksWrapper, I guess
    while (linkCount > 0) {
        wrapper.firstChild.remove();
        linkCount--;
    }
}

Sometimes it does work, but other times the first N links are not those which start from the root.

I have also considered overriding connectionsUpdate as explained here to prevent their generation altogether, but the state.connectionsUpdate function / option does not seem to be called at all (I have tried putting debugger / alert into it and they do not seem to get reached).

m-gallesio avatar Oct 07 '22 12:10 m-gallesio

You can also use chart.connections to fake multi root

bumbeishvili avatar Dec 27 '22 16:12 bumbeishvili