Skip to content

Commit

Permalink
feat: Add depthOffset attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikGartner committed Jan 2, 2016
1 parent b1092a4 commit 7037257
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The data object should have the following structure:
name: "Father",
class: "overriding-css-class",
textClass: "overriding-css-class",
depthOffset: 1,
marriage: {
spouse: {
name: "Mother",
Expand Down
22 changes: 18 additions & 4 deletions src/dtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ const dTree = {
class: person.class
};

// hide linages to the hidden root node
if (parent == root) {
node.noParent = true;
}

// apply depth offset
for (var i = 0; i < person.depthOffset; i++) {
var pushNode = {
name: '',
id: id++,
hidden: true,
children: [],
noParent: node.noParent
};
parent.children.push(pushNode);
parent = pushNode;
}

// sort children
dTree._sortPersons(person.children, opts);

Expand Down Expand Up @@ -125,10 +143,6 @@ const dTree = {
reconstructTree(person, root);
});

_.forEach(root.children, function(child) {
child.noParent = true;
});

return {
root: root,
siblings: siblings
Expand Down

0 comments on commit 7037257

Please sign in to comment.