BALKANGraph / FamilyTreeJS

Build family tree app with BALKAN FamilyTreeJS library. Family Tree also called a genealogy or a pedigree chart, is a chart representing family relationships in a conventional tree structure.
60 stars 17 forks source link

Roots confusion #130

Open rctneil opened 3 months ago

rctneil commented 3 months ago

Hi,

Just started having a play around with this library and really loving it so far.

I'm getting confused about what the roots option does.

Basically when my tree is loaded i'm getting the wrong branch of the family showing by default.

I have a person who I want to be visible by default, but when I add roots: [4] to the options, it doesn't make any difference.

Can you explain what the roots option is for and if I am trying to do this the right way?

Thanks

ZornitsaPesheva commented 3 months ago

Hi Neil

I guess you understand roots, but there is a restriction that only a top-level node can be a root. So, if you'd like to see 4, you should set the root of node 4 in the root option. Here is an example: https://code.balkan.app/family-tree-js/set-root#JS

rctneil commented 3 months ago

But that's the issue. Node 4 IS a top level. Adding roots: [4] doesn't make any difference.

I have noticed though that the order of the People as they get pulled out of my database seems to make a difference? Why?

Surely I should be able to specify a root and then everything flows from there?

ZornitsaPesheva commented 3 months ago

Please create a code example of what you have in our Code app: https://code.balkan.app/familytreejs/getting-started#JS

rctneil commented 3 months ago

Here's an example:

https://code.balkan.app/root-issue

Node ID 4 is what I want as the root.

rctneil commented 3 months ago

Node 4 is the main node we wish to be visible when the tree initially loads.

ZornitsaPesheva commented 3 months ago

If you move the node id 4 in the beginning of the array, it will work. There are some known issues in FamilyTree JS, but now we are working on a new implementation where all nodes could be visible. You can follow un in LinkedIn for any news.

rctneil commented 3 months ago

Ok, Please can you explain what root actually does?

What is the defintion of a root node, why can you specify multiple in options?

Are root people always at the top level of your tree?

I've just been messing with my dev app by moving certain people nodes to the top of the node data list and sometimes it changes the tree view and other times not. I just need some more defintion as to what a root is and what effect changing it actually has

ZornitsaPesheva commented 3 months ago

Root option set a node as a root in the tree. You can specify multiple roots because you can have multiple trees in one family object. Yes, the root people are at the top level.

rctneil commented 3 months ago

Ok, So I do wonder:-

  1. If the people in the data array is in a certain order (ie: not having the root person at the top), when setting the roots: option, that should overcome that shouldn't it?

  2. So if the root is set to a person that has a parent, what happens then?

Sorry, just trying to get my head around all this.

rctneil commented 3 months ago

I am not trying to show ALL nodes. I understand that. Just wondering why the roots option gets ignored really?

Also, as per 2. above. Whats happens if you specify the root to be a person that has a parent? You stated above that roots need to be top level, so what happens if you set a node with a parent as the root?

ZornitsaPesheva commented 3 months ago

The order that is changing the tree is known issue. Also the root have to be a top level is know issue. All these will not be present in the new FamilyTree JS as there it will be possible to see the whole tree.