bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
928 stars 330 forks source link

The org cannot have two or more people as supreme leader #238

Closed MateoCaicedoW closed 1 year ago

MateoCaicedoW commented 1 year ago

Describe the bug when there are two or more people as a leader the library doesn't work

bumbeishvili commented 1 year ago

Yes. we don't support two parents. For the workaround, it's possible to use connections, to connect any node to any node

https://stackblitz.com/edit/js-tpbt7r?file=index.html

jaofrod commented 1 year ago

Or you could set a "fake-root" as the supreme leader and then just set its properties so it doesnt appears to be on screen:

.childrenMargin((d) => { return d.depth === 0 ? -100 : 120; }) .linkUpdate(function (d) { d3.select(this) { if (d.depth === 1) { d3.select(this).attr('display', 'none'); } } }) .nodeUpdate(function (d) { if (d.depth === 0) { d3.select(this).attr('display', 'none'); d.height = 0; d.width = 0; } })

bumbeishvili commented 1 year ago

check #59, #138

MateoCaicedoW commented 1 year ago

great! but, if I want expand the two first levels, how can I get that? @devjaof

MateoCaicedoW commented 1 year ago

is there any way to expand the 3 first levels? @bumbeishvili

jaofrod commented 1 year ago

great! but, if I want expand the two first levels, how can I get that? @devjaof

I dont know if this is the best solution for this problem, but to do this i created a method that returns the children of two first levels and then i set each one of the children as expanded using chat.setExpanded(node) where node is the children i want to keep expanded;

@bumbeishvili can you confirm if there is a cleanest way to keep those childrens expanded?

bumbeishvili commented 1 year ago

I don't think that currently there is another way.

In the future, you will be able to set expandLevelinitially, it does not work currently

https://github.com/bumbeishvili/org-chart/blob/c8ebb0490ecfcf1424c16a8528a4a835d3efde53/src/d3-org-chart.js#L37

jaofrod commented 1 year ago

I don't think that currently there is another way.

In the future, you will be able to set expandLevelinitially, it does not work currently

https://github.com/bumbeishvili/org-chart/blob/c8ebb0490ecfcf1424c16a8528a4a835d3efde53/src/d3-org-chart.js#L37

Great!

MateoCaicedoW commented 1 year ago

I made this to solve this problem let secondLevel = rawData.filter((d) => d.parentId == 1); rawData.forEach((d) =>{ if (d.parentId !== 1 && secondLevel.some((e) => e.id == d.parentId)) { d._expanded = true; } });

My first level is a node with 1 as ID.

bumbeishvili commented 1 year ago

I am updating the expand-level functionality.

From now on you. can configure the depth at which the org chart will open

chart.initialExpandLevel(0) // Only root node will open

chart.initialExpandLevel(1) // Default behavior, root and it's children will be expanded

chart.initialExpandLevel(2) // All nodes with depth 2 will be expanded