Class: Node

Node

new Node(pos, props)

Constructs a new Node
Parameters:
Name Type Description
pos Array Array of three Numbers representing the position of the Node in 3D space (x, y, z)
props Object Object containing optional properties of the Node
Properties
Name Type Description
id Number | String | null Optional unique identifier; Numbers will be converted into Strings; defaults to null
color Number | String Hexadecimal or CSS-style string representation of a color; defaults to 'white'
Source:

Methods

(private) _initProps(properties) → {Node}

Initialize Node properties
Parameters:
Name Type Description
properties Object Options passed in from the constructor
Source:
Returns:
The Node the method was called on
Type
Node

addTo(graph) → {Node}

Add the Node to a Graph
Parameters:
Name Type Description
graph Graph Graph the Node will be added to
Source:
Returns:
The Node the method was called on
Type
Node

color() → {String}

Get the color of the Node
Source:
Returns:
String hexadecimal representation of the Edge's color
Type
String

id() → {String|Number|null}

Get the ID of the Node
Source:
Returns:
ID of the Node
Type
String | Number | null

pos() → {Array}

Get the position of the Node
Source:
Returns:
Array of three Numbers representing the position of the Node in 3D space (x, y, z)
Type
Array
Example
var x = 14, y = 20, z = -5;
myNode.pos() === [14, 20, -5];

setColor(color)

Set the color of the Node
Parameters:
Name Type Description
color Number | String Hexadecimal or CSS-style string representation of a color
Source:
Returns:
The Node the method was called

setPos(pos) → {Node}

Set the position of the Node
Parameters:
Name Type Description
pos Array Array of three Numbers representing the position of the Node in 3D space (x, y, z)
Source:
Returns:
The Node the method was called on
Type
Node
Example
var x = 14, y = 20, z = -5;
myNode.setPos([x, y, z]);