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

How to add "selected" tag to a node #133

Open frankbracq opened 1 month ago

frankbracq commented 1 month ago

Hi,

Could you show me an example of code to add the ‘selected’ tag to a node?

Hereafter an extract of the code I'm uisng

reaction( () => configStore.config.root, (rootId) => { if (!initializing) { if (!family) { initializeFamilyTree(); } const oldestAncestorId = getOldestAncestorOf(rootId, "both"); family.config.roots = [oldestAncestorId]; console.log('Family', family);

        **// sample code to be implemented here**

        // addFocusedTag(nodeData);

        family.draw();
    }
}

);

function addFocusedTag(node) { if (!node.tags.includes('selected')) { node.tags.push('selected'); } }

Thanks in advance

ZornitsaPesheva commented 1 month ago

Please check if this is what you need to achieve: https://code.balkan.app/org-chart-js/select-and-deselect-on-node-click-only#JS