Skip to content

Latest commit

 

History

History
113 lines (64 loc) · 3.77 KB

angular-docs-apps-model-querying.md

File metadata and controls

113 lines (64 loc) · 3.77 KB

Querying the model

The VisuallyJs model offers several methods to query the hierarchy of nodes and groups.

Groups​

When you have a hierarchical model where nodes or groups can be nested within other groups, you can use these methods to navigate the hierarchy.

Ancestor groups​

getAncestors​

Gets a list of groups that are ancestors of the given node/group (or port, for which we first resolve the node/group it resides on). The list of ancestors is ordered in terms of their proximity to the focus, ie. the first entry is the focus vertex's immediate parent.

Signature

getAncestors(vertex:Vertex)

Parameters

vertex Vertex

Return value

Array<Group>

Descendants of a group​

getDescendants​

Gets a list of nodes/groups that are descendants of the given group.

Signature

getDescendants(vertex:Group)

Parameters

vertex Group

Return value

Array<Node | Group>

Testing for ancestor​

isAncestor​

Returns whether or not possibleAncestor is in fact an ancestor of the given focus node/group

Signature

isAncestor(focus:Vertex, possibleAncestor:Group)

Parameters

focus Vertex Vertex to test
possibleAncestor Group Group which may be an ancestor of focus

Return value

boolean

Testing for descendant​

isDescendantGroup​

Determine whether possibleDescendant is in fact a descendant of the ancestor group

Signature

isDescendantGroup(possibleDescendant:Group, ancestor:Group)

Parameters

possibleDescendant Group Group to test
ancestor Group Ancestor group

Return value

boolean

Selecting descendants​

While the methods above return arrays of objects, you may sometimes want to perform selection-based operations on a hierarchy.

selectDescendants​

Selects all descendants of some Node or Group, and, optionally, the Node/Group itself.

Signature

selectDescendants(obj:string | Node | Group, includeFocus:boolean, includeEdges:boolean)

Parameters

obj string | Node | Group Node/Group, or ID of Node/Group, to select
includeFocus boolean Whether or not to include the focus node/group in the returned dataset. Defaults to false.
includeEdges boolean Whether or not to include edges in the returned dataset. Defaults to false.

Return value

VisuallyJsSelection