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.
50 stars 16 forks source link

Partner node's children is empty #79

Closed pandabytes closed 8 months ago

pandabytes commented 8 months ago

Hello! I notice that when I display the number of children of a node (called it A), it correctly shows the number of child nodes. However, if I select the partner node of node A, it shows 0 children. Given node A's partner node, how can I get the correct child nodes?

Here is an example to show what I'm describing.

//JavaScript
var family = new FamilyTree(document.getElementById("tree"), {
    mouseScrool: FamilyTree.action.none,
    nodeBinding: {
        field_0: "name"
    },
    nodeMenu: {
        show: {
            text: 'Show children count',
            onClick: (nodeID) => {
                const node = family.getNode(nodeID);
                // Same for node.childrenIds
                alert(`nodeID=${nodeID}, children=${node.children.length}`);
            }
        }
    },
    nodes: [
        { id: 1, pids: [2], name: "Amber McKenzie", gender: "female" },
        { id: 2, pids: [1], name: "Ava Field", gender: "male" },
        { id: 3, mid: 1, fid: 2, name: "Peter Stevens", gender: "male" }
    ]
});

In this example, if you select Show children count on node Amber McKenzie the alert displays 2 children nodes (Ava Field and Peter Stevens). However if you do the same for node Ava Field, it displays 0 children. I would expect it to display 2 children nodes (Amber McKenzie and Peter Stevens).

ZornitsaPesheva commented 8 months ago

You should use ftChildrenIds https://code.balkan.app/family-tree-js/children-count#JS

pandabytes commented 8 months ago

Thank you!