data
Array<Object> Array of objects to be turned into a tree.options
Object Additional options for HierarchyTree.options.childKey
string Key in the tree where children will be stored. When no children this property is undefined. (optional, default'children'
)options.hierarchyKey
string Key in the input data where hierarchy level is indicated. (optional, default'hierarchy'
)options.maxHierarchy
number? Maximum hierarchy depth. If not provided it will be recursively found.options.hierarchyStart
number First level where the hierarchies will start. (optional, default1
)options.parentObjects
parentObjects Gives child its parent items (with 'parentKeys' properties). (optional, defaultfalse
)options.parentKey
parentKey Key for object where childrens' parents will be stored. When item has no parents this property is undefined. (optional, default'parents'
)options.parentKeys
parentKeys When 'parentObjects' is true, each child will have its parents stored with these properties. (optional, default[]
)
Finds the depth of the tree.
Returns void
A generator function slicing items into subsets of parents with its children.
items
Array<Object> (Sub)Set of items in data array.hierarchy
number Level (depth) of current hierarchy.
Returns Array<Object> Array of objects with a parent and its children.
items
Array<Object> (Sub)Set of items in data array which will be used to create the tree. Each set has parent and its children.hierarchy
number Level (depth) of current hierarchy.parents
Array<Object> Parent nodes of current set with keys specified by 'parentKeys'. (optional, default[]
)
Returns Array<Object> Array of objects where each element has parent spread into the object and its children as 'childKey' prop in then object. Does not prouce empty array with 'childKey' on leaf child.
Returns Array<Object> Tree. It is built once, returns same tree on each call.