Skip to content

NgDiagramNodeService

since v0.8.0

The NgDiagramNodeService provides methods for manipulating nodes in the diagram.

private nodeService = inject(NgDiagramNodeService);
// Move nodes by a delta
this.nodeService.moveNodesBy([node1, node2], { x: 10, y: 20 });
  • NgDiagramBaseService

bringToFront(nodeIds?, edgeIds?): Promise<void>

Brings the specified nodes and edges to the front (highest z-index).

string[]

Array of node IDs to bring to front.

string[]

Array of edge IDs to bring to front.

Promise<void>

A promise that resolves once the change has been applied to the model. Inside a transaction, the promise resolves right away and the change is applied when the transaction commits.


moveNodesBy(nodes, delta): Promise<void>

Moves nodes by the specified amounts.

Node[]

Array of nodes to move.

Point

The amount to move the nodes by.

Promise<void>

A promise that resolves once the change has been applied to the model. Inside a transaction, the promise resolves right away and the change is applied when the transaction commits.


resizeNode(id, size, position?, disableAutoSize?, options?): Promise<void>

Resizes a node to the specified dimensions. Node.autoSize must be set to false to resize a node.

string

The ID of the node to resize.

Size

The new size of the node.

Point

Optional new position of the node.

boolean

Optional flag to disable auto-sizing.

Optional settings. Set waitForMeasurements: true to resolve only after measurements triggered by the resize have completed. Available since 1.3.0.

boolean

Promise<void>

A promise that resolves once the change has been applied to the model. Inside a transaction, the promise resolves right away and the change is applied when the transaction commits.


rotateNodeTo(nodeId, angle): Promise<void>

Rotates a node to the specified angle.

string

The ID of the node to rotate.

number

The rotation angle in degrees.

Promise<void>

A promise that resolves once the change has been applied to the model. Inside a transaction, the promise resolves right away and the change is applied when the transaction commits.


sendToBack(nodeIds?, edgeIds?): Promise<void>

Sends the specified nodes and edges to the back (lowest z-index).

string[]

Array of node IDs to send to back.

string[]

Array of edge IDs to send to back.

Promise<void>

A promise that resolves once the change has been applied to the model. Inside a transaction, the promise resolves right away and the change is applied when the transaction commits.