@graphty/graphty-element / Node / Node
Class: Node
Defined in: src/Node.ts:28
Represents a node in the graph visualization with its mesh, label, and associated data. Manages node rendering, styling, drag behavior, and interactions with the layout engine.
Constructors
Constructor
new Node(
graph,nodeId,styleId,data,opts):Node
Defined in: src/Node.ts:66
Creates a new Node instance with mesh, label, and behaviors.
Parameters
graph
The parent graph or graph context that owns this node
nodeId
Unique identifier for this node
styleId
Style identifier determining the node's visual appearance
data
AdHocData<string | number>
Custom data associated with this node
opts
NodeOpts = {}
Optional configuration options for the node
Returns
Node
Properties
algorithmResults
algorithmResults:
AdHocData
Defined in: src/Node.ts:33
changeManager
changeManager:
ChangeManager
Defined in: src/Node.ts:42
data
data:
AdHocData<string|number>
Defined in: src/Node.ts:32
dragging
dragging:
boolean=false
Defined in: src/Node.ts:38
dragHandler?
optionaldragHandler:NodeDragHandler
Defined in: src/Node.ts:37
id
id:
NodeIdType
Defined in: src/Node.ts:31
label?
optionallabel:RichTextLabel
Defined in: src/Node.ts:36
mesh
mesh:
AbstractMesh
Defined in: src/Node.ts:35
opts
opts:
NodeOpts
Defined in: src/Node.ts:30
parentGraph
parentGraph:
GraphContext|Graph
Defined in: src/Node.ts:29
pinOnDrag
pinOnDrag:
boolean
Defined in: src/Node.ts:40
size
size:
number
Defined in: src/Node.ts:41
styleId
styleId:
NodeStyleId
Defined in: src/Node.ts:39
styleUpdates
styleUpdates:
AdHocData
Defined in: src/Node.ts:34
Methods
addCalculatedStyle()
addCalculatedStyle(
cv):void
Defined in: src/Node.ts:123
Adds a calculated style value to this node's change manager.
Parameters
cv
CalculatedValue
The calculated value to add to the node's styling system
Returns
void
getPosition()
getPosition():
object
Defined in: src/Node.ts:418
Gets the current 3D position of the node's mesh.
Returns
object
An object containing the x, y, and z coordinates of the node
x
x:
number
y
y:
number
z
z:
number
isPinned()
isPinned():
boolean
Defined in: src/Node.ts:430
Checks whether the node is currently pinned in place.
Returns
boolean
True if the node is pinned, false otherwise
isSelected()
isSelected():
boolean
Defined in: src/Node.ts:439
Checks whether the node is currently selected.
Returns
boolean
True if the node is selected, false otherwise
pin()
pin():
void
Defined in: src/Node.ts:267
Pins the node in place, preventing the layout engine from moving it.
Returns
void
unpin()
unpin():
void
Defined in: src/Node.ts:274
Unpins the node, allowing the layout engine to move it again.
Returns
void
update()
update():
void
Defined in: src/Node.ts:131
Updates the node's mesh position and style based on layout engine and style changes. Handles mesh recreation if disposed and applies any pending style updates.
Returns
void
updateStyle()
updateStyle(
styleId):void
Defined in: src/Node.ts:177
Updates the node's visual style by recreating the mesh with the specified style. Preserves the node's position and reattaches behaviors and labels.
Parameters
styleId
The new style identifier to apply to the node
Returns
void