!!!###!!!title=API——VisActor/VGraph tutorial documents!!!###!!!

Group Instance Methods

Visibility and State Management

Instance MethodReturn ValueDescription
show()voidShows the group.
hide()voidHides the group.
isVisible()booleanQueries the visibility state of the group.
collapse()voidCollapses the nodes within the group, leaving only the title and connections. If no title is defined, the effect is the same as hide. The corresponding data will be modified to collapsed = true. Therefore, you must ensure that the collapsed field has no business meaning, otherwise it will be overwritten. If it is a custom title, the title will also be refreshed at this time.
expand()VoidExpands the nodes within the group. The corresponding data will be modified to collapsed = false. Therefore, you must ensure that the collapsed field has no business meaning, otherwise it will be overwritten. If it is a custom title, the title will also be refreshed at this time.
setState(state: string, onlyState=false)voidSets the group state. This is a convenient method for when the group structure remains unchanged but its appearance changes. For details on usage, see the State Management section.
clearStates()voidClears all group states.
removeState(state: string)voidRemoves the specified state of the group.

Relationship Query

Instance MethodReturn ValueDescription
get(key: string)anyGets a configuration item on the group.
set(key: string, value: any)voidUpdates a business data item on the group. This is an operation that does not involve graphic changes. If you need the update to be reflected in the graph, please use updateData.
updateData(data: NodeData)voidUpdates the group data. It supports incremental data updates and will merge with the old data. This will cause the connection graphics to be updated.
addChild(child: Node | Group)voidAdds a child node or group. If you are adding in batches, you can use addChildrenByIds for better performance.
addChildrenByIds(ids: string[])voidAdds child nodes or groups in batches.
removeChild(child: Node | Group, destroy = true)voidRemoves an instance from the group. By default, the removed instance will be destroyed. You can set destroy = false to keep the instance. If you are removing in batches, you can use removeChildrenByIds for better performance.
removeChildrenByIds(id: string[], desroy = true)voidRemoves child nodes in batches. By default, the removed instances will be destroyed. You can set destroy = false to keep the instances.

Graphics Operations

Instance MethodReturn ValueDescription
getBBox()BBoxGets the group's box model.
translate(x: number, y: number)voidTranslates the entire group, including the child nodes and groups within the group.
getKeyShape()ShapeGets the key shape of the group.
getLayer()LayerGets the group's drawing container, from which you can further get all internal graphics.
getTitleLayer()Layer | nullGets the group title container (if configured).

Event Operations

Instance MethodReturn ValueDescription
on(eventType: string, callback(e: GraphEvent) => void)voidAdds a handler for a specific event on the group. For more information about events, see the Event Guide.
once(eventType: string, callback(e: GraphEvent) => void)voidAdds a one-time event handler on the group.
emit(eventType: string, args: any)voidTriggers a specified event on the group.
off(eventType: string, callback(e: GraphEvent) => void)voidRemoves a handler for a specific event on the group.
removeAllListeners()voidRemoves all event handlers on the group.