Programmatically Modify Family Tree JS 2
Use the following methods to add relatives to the tree in code.
addChild
The code below adds a child to the node with id 3:
javascript
familyTree.addChild(3).draw();The code below adds a child to the nodes with ids 1 and 2:
javascript
familyTree.addChild(1, 2).draw();addFather
The code below adds a father to the node with id 2:
javascript
familyTree.addFather(2).draw();addMother
The code below adds a mother to the node with id 2:
javascript
familyTree.addMother(2).draw();addSibling
The code below adds a sibling to the node with id 3:
javascript
familyTree.addSibling(3).draw();addSpouse
The code below adds a spouse to the node with id 3:
javascript
familyTree.addSpouse(3).draw();addUnmarriedPartner
The code below adds an unmarried partner to the node with id 3:
javascript
familyTree.addUnmarriedPartner(3).draw();