NgDiagramNodeService
since v0.8.0The NgDiagramNodeService provides methods for manipulating nodes in the diagram.
Example usage
Section titled “Example usage”private nodeService = inject(NgDiagramNodeService);
// Move nodes by a deltathis.nodeService.moveNodesBy([node1, node2], { x: 10, y: 20 });Extends
Section titled “Extends”NgDiagramBaseService
Methods
Section titled “Methods”bringToFront()
Section titled “bringToFront()”bringToFront(
nodeIds?,edgeIds?):Promise<void>
Brings the specified nodes and edges to the front (highest z-index).
Parameters
Section titled “Parameters”nodeIds?
Section titled “nodeIds?”string[]
Array of node IDs to bring to front.
edgeIds?
Section titled “edgeIds?”string[]
Array of edge IDs to bring to front.
Returns
Section titled “Returns”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()
Section titled “moveNodesBy()”moveNodesBy(
nodes,delta):Promise<void>
Moves nodes by the specified amounts.
Parameters
Section titled “Parameters”Node[]
Array of nodes to move.
The amount to move the nodes by.
Returns
Section titled “Returns”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()
Section titled “resizeNode()”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.
Parameters
Section titled “Parameters”string
The ID of the node to resize.
The new size of the node.
position?
Section titled “position?”Optional new position of the node.
disableAutoSize?
Section titled “disableAutoSize?”boolean
Optional flag to disable auto-sizing.
options?
Section titled “options?”Optional settings. Set waitForMeasurements: true to resolve only after
measurements triggered by the resize have completed. Available since 1.3.0.
waitForMeasurements?
Section titled “waitForMeasurements?”boolean
Returns
Section titled “Returns”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()
Section titled “rotateNodeTo()”rotateNodeTo(
nodeId,angle):Promise<void>
Rotates a node to the specified angle.
Parameters
Section titled “Parameters”nodeId
Section titled “nodeId”string
The ID of the node to rotate.
number
The rotation angle in degrees.
Returns
Section titled “Returns”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()
Section titled “sendToBack()”sendToBack(
nodeIds?,edgeIds?):Promise<void>
Sends the specified nodes and edges to the back (lowest z-index).
Parameters
Section titled “Parameters”nodeIds?
Section titled “nodeIds?”string[]
Array of node IDs to send to back.
edgeIds?
Section titled “edgeIds?”string[]
Array of edge IDs to send to back.
Returns
Section titled “Returns”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.