Show / Hide Table of Contents

How to create a Family Tree JS programmatically

There are number of ways to create Family Tree JS programmatically

Using addParentNode function

Here is an example:

 
    family.addParentNode(1, "mid", {id: 0, name: "Amber McKenzie's mother", gender: "female"});


Using addPartnerNode function

Here is an example:

 
    family.addPartnerNode({id: 6, pids: [3], name: "Peter Stevens's wife", gender: "female"});


Using addChildNode function

Here is an example:

 
    family.addChildNode({id: 6, mid: 1, fid: 2, name: "Amber and Ava's child", gender: "female"});


Using addChildAndPartnerNodes function

Here is an example:

 
      family.addChildAndPartnerNodes(3, 
        {id: 7, mid: 6, fid: 3, name: "Peter's child", gender: "female"},
        {id: 6, pids: [3], tipe: "mid", name: "Peter's wife",  gender: "female"});
      });