Class: Graph

Graph

new Graph(props)

Constructs a new Graph
Parameters:
Name Type Description
props Object Object containing optional properties of the Graph
Properties
Name Type Description
antialias Boolean 'true' if antialiasing should be enabled on the graph. Defaults to 'false'.
fov Number Degree represting the field of view for the camera. Defaults to 45.
sizeAttenuation Boolean 'true' if nodes' size should change with distance. Defaults to 'false'.
nodeImage String Path to an image to use for the graph nodes, defaults to no image.
nodeImageTransparent Boolean 'true' if the node image has transparency, defaults to 'false'.
nodeSize Number Number representing the size (in pixels) of the nodes within the graph, defaults to 10
edgeOpacity Number Number (between 0 and 1) indicating the percentage opacity of the edges, defaults to 1 (100%)
edgeWidth Number Number representing the width (in pixels) of the edges within the graph, defaults to 1
bgColor Number | String Hexadecimal or CSS-style string representation the color of the background, defaults to 'white'
bgOpacity Number Number (between 0 and 1) indicating the percentage opacity of the background, defaults to 1 (100%)
hover function Callback function that will be called when the mouse hovers over a node. Event data will be passed as a parameter to the callback.
click function Callback function that will be called when the mouse clicks a node. Event data will be passed as a parameter to the callback.
Source:

Methods

(private) _resolveEdgeIds(edge) → {undefined}

Replace string IDs representing Nodes in Edges with Node references
Parameters:
Name Type Description
edge Edge Edge that has string IDs for its Node values
Source:
Returns:
Type
undefined

addEdge()

Add an Edge to the Graph. Upon adding, if the Edge contains Node string ID's, they will be looked up in the Graph and replaced with Node instances.
Source:

addEdges(edges)

Add multiple edges at the same time.
Parameters:
Name Type Description
edges Array array of Edge objects, or edge parameters.
Source:

addNodes(nodes)

Add multiple nodes at the same time
Parameters:
Name Type Description
nodes Array array of Node objects to add, as you would using the addNode function
Source:

disableAutoRender()

Stops the chart from rendering newly added data (e.g. edges/nodes)
Source:

enableAutoRender()

Re-enables rendering newly added data (e.g. edges/nodes)
Source:

purgeEdges()

Removes all the edges from the graph.
Source:

purgeNodes()

Removes all nodes from the Graph. Implies removing all the edges, as well, since they'd no longer be connected to anything.
Source:

renderIn(elem) → {Graph}

Render the Graph in a DOM element
Parameters:
Name Type Description
elem Element | String Element the Graph should be rendered in. Specify Element ID if string.
Source:
Returns:
The Graph the method was called on
Type
Graph