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

Instance Methods

State Management

Instance MethodReturn ValueDescription
setState(state: string, onlyState=false)voidSet the edge state. This is a convenient method for when the edge structure does not change, but its appearance does. For more details, see the State Management section.
clearStates()voidClear all edge states.
removeState(state: string)voidRemove a specific state from the edge.
show()voidShow the edge.
hide()voidHide the edge.
isVisible()booleanQuery the visibility state of the edge.
toFront()booleanMove the edge to the front of all edges.
toBack()booleanMove the edge to the back of all edges.

Relationship Query

Instance MethodReturn ValueDescription
get(key: string)anyGet a specific configuration item on the edge.
set(key: string, value: any)voidUpdate a business data item on the edge. 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)voidUpdate edge data. It supports differential data updates and will be merged with old data, which will cause the edge graphics to update.
setSource(sourceId: string)voidSet the source node of the edge. It may not actually connect to this node, as it depends on the group and configuration of the node.
setTarget(targetId: string)voidSet the target node of the edge. It may not actually connect to this node, as it depends on the group and configuration of the node.
getSource()Node |GroupGet the source entity to which the edge is actually connected.
getTarget()Node |GroupGet the target entity to which the edge is actually connected.

Graphic Operations

Instance MethodReturn ValueDescription
getBBox()BBoxGet the bounding box of the edge.
getKeyShape()ShapeGet the key shape of the edge, which is generally a path.
getLayer()voidGet the drawing container of the edge, from which you can further get all internal graphics.
getLabel()Text |undefinedGet the text label graphic (if configured).
setOpacity()voidSet the opacity of the entire edge, including text labels, etc.

Event Operations

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