lp-tree-node
A node structure extends from d3-node
APIs
append (node: Node) => this: Node
Append a new Node or SubTree to this
var Node = ;var data1 ="name": "Eve""name": "Cain" "parent": "Eve""name": "Seth" "parent": "Eve""name": "Enos" "parent": "Seth""name": "Noam" "parent": "Seth""name": "Abel" "parent": "Eve""name": "Awan" "parent": "Eve""name": "Enoch" "parent": "Awan""name": "Azura" "parent": "Eve";var data2 ="id": "Evan""id": "Yoo" "parentId": "Evan""id": "Yuka" "parentId": "Evan";var rootTree = Nodeid dname // define how to get [id] from data (default data.id)// define how to get [parentId] from data (default data.parentId); // bind datavar subTree = Node;var targetNode = rootTree; // get the parent nodetargetNode; // append the [subTree] to [targetNode]
Notice:
- After the operation, all nodes in the root tree will update. (renew height, depth, value fields)
remove () => this: Node
Remove a Node from its parent
findBefore (exp: (node: Node) => boolean): Node
Get the first Node which make exp to be true in pre-order traversal
findAfter (exp: (node: Node) => boolean): Node
Get the first Node which make exp to be true in post-order traversal