documentationfor yFiles for HTML 3.0.0.3

Nodes

A node is a graph item that represents an entity. It is modeled by the interface INode. INode provides properties that define the node’s characteristics. All properties, except tag, are read-only. You can set their values using the corresponding methods on IGraph.

Property Setter Description

INode.layout

IGraph.setNodeLayout

The node’s layout, i.e., its location and size. See about node layout.

INode.style

IGraph.setStyle

The visual appearance of the node. See Visualizing Graph Elements.

INode.labels

IGraph.addLabel

The collection of labels associated with this node.

INode.ports

IGraph.addPort

The collection of ports associated with this node.

INode.tag

INode.tag

An object of arbitrary type which can be used to bind user data to this node. See Storing Business Data for Graph Elements. Note that this is the only property that provides both getter and setter.

Node properties
graph model node bounds
Layout
graph model node styles
Style
graph model node labels
Labels
graph model node ports
Ports

Nodes cannot be created with a constructor directly. Instead, create and remove nodes from the graph using IGraph’s methods:

Creating and removing nodes:
createNode(layout: Rect, style: INodeStyle, tag: Object): INode
createNodeAt(location: Point, style: INodeStyle, tag: Object): INode
createNode(parent: INode, layout: Rect, style: INodeStyle, tag: Object): INode

Creates a node. The overloads allow setting the new node’s properties at creation time. Values not passed as parameters will be set to the default values as defined in the node defaults.

remove(item: IModelItem): void

Removes the specified node from the graph. Before the node is removed, all dependent items (the node’s labels and ports, and also adjacent edges) are removed.

Important
You can only modify or remove nodes that are part of the current graph instance. Trying to modify or remove a node that has already been removed will result in an exception. Also, if your use case involves several IGraph instances (especially if you are using filtering or folding), take care to modify and remove nodes only with the graph the node belongs to.