This is a list of all the methods in the public API. They have been grouped by category, which correspond to
the
modules listed above.
destroy() |
Returns: none |
Remove the network from the DOM and remove all Hammer bindings and references. |
setData({nodes: vis
DataSet/Array ,edges: vis
DataSet/Array })
|
Returns: none |
Override all the data in the network. If stabilization is enabled in the physics
module, the network will stabilize again. This method is also performed when first initializing
the
network.
|
setOptions(Object
options )
|
Returns: none |
Set the options. All available options can be found in the modules above. Each module requires it's
own
container with the module name to contain its options.
|
canvasToDOM({x:
Number ,y:
Number })
|
Returns: Object |
This function converts canvas coordinates to coordinates on the DOM. Input and output are in the
form of
{x:Number,y:Number} . The DOM values are relative to the network container.
|
DOMtoCanvas({x:
Number ,y:
Number })
|
Returns: Object |
This function converts DOM coordinates to coordinates on the canvas. Input and output are in the
form of
{x:Number,y:Number} . The DOM values are relative to the network container.
|
redraw() |
Returns: none |
Redraw the network. |
setSize(String
width ,String
height )
|
Returns: none |
Set the size of the canvas. This is automatically done on a window resize. |
cluster(
Object options )
|
Returns: none |
The options object is explained in full below. The joinCondition
function
is presented with all nodes.
|
clusterByConnection(
String nodeId ,
[Object options]
)
|
Returns: none |
This method looks at the provided node and makes a cluster of it and all it's connected nodes. The
behaviour can be customized by proving the options object. All options of this object are explained
below. The joinCondition is only presented with the connected
nodes.
|
clusterByHubsize(
Number hubsize ,
[Object options] )
|
Returns: none |
This method checks all nodes in the network and those with a equal or higher amount of edges than
specified with the hubsize qualify. Cluster by connection is performed on each of them.
The
options object is described for clusterByConnection and does the same here.
|
clusterOutliers(
[Object options] )
|
Returns: none |
This method will cluster all nodes with 1 edge with their respective connected node. |
findNode(
String nodeId )
|
Returns: Array |
Nodes can be in clusters. Clusters can also be in clusters. This function returns and array of
nodeIds
showing where the node is.
Example:
cluster 'A' contains cluster 'B',
cluster 'B' contains cluster 'C',
cluster 'C' contains node 'fred'.
network.clustering.findNode('fred') will return ['A','B','C','fred'] .
|
isCluster(
String nodeId )
|
Returns: Boolean |
Returns true if the node whose ID has been supplied is a cluster. |
openCluster(
String nodeId )
|
Returns: none |
Opens the cluster, releases the contained nodes and edges, removing the cluster node and cluster
edges.
|
getSeed() |
Returns: Number |
If you like the layout of your network and would like it to start in the same way next time, ask for
the
seed using this method and put it in the layout.randomSeed option.
|
enableEditMode() |
Returns: none |
Programatically enable the edit mode. Similar effect to pressing the edit button. |
disableEditMode() |
Returns: none |
Programatically disable the edit mode. Similar effect to pressing the close icon (small cross in the
corner of the toolbar).
|
addNodeMode() |
Returns: none |
Go into addNode mode. Having edit mode or manipulation enabled is not required. To get out of this
mode,
call disableEditMode() . The callback functions defined in handlerFunctions
still apply. To use these methods without having the manipulation GUI, make sure you set
enabled to false.
|
editNodeMode() |
Returns: none |
Go into editNode mode. The explaination from addNodeMode applies here as well. |
addEdgeMode() |
Returns: none |
Go into addEdge mode. The explaination from addNodeMode applies here as well. |
editEdgeMode() |
Returns: none |
Go into editEdge mode. The explaination from addNodeMode applies here as well. |
deleteSelected() |
Returns: none |
Delete selected. Having edit mode or manipulation enabled is not required. |
getPositions([Array of
nodeIds] )
|
Returns: Object |
Returns the x y positions in canvas space of the nodes with the supplied nodeIds as an object:
{
nodeId1: {x: xValue, y:yValue},
nodeId2: {x: xValue, y:yValue},
...
}
Alternative inputs are a String containing a nodeId or nothing. When a String is supplied, the
position
of the node corresponding to the ID is returned. When nothing is supplied, the positions of all
nodes
are returned.
|
storePositions() |
Returns: none |
When using the vis.DataSet to load your nodes into the network, this method will put the X and Y
positions of all nodes into that dataset. If you're loading your nodes from a database and have
this dynamically coupled with
the DataSet, you can
use this to stablize your network once, then save the positions in that database through the DataSet
so
the next
time you load the nodes, stabilization will be near instantaneous.
If the nodes are still moving and you're using dynamic smooth edges (which is on by default), you
can
use the option stabilization.onlyDynamicEdges in the physics
module
to improve initialization time.
This method does not support clustering. At the moment it is not possible to cache
positions when using clusters since they cannot be correctly initialized from just the
positions.
|
getBoundingBox(String
nodeId )
|
Returns: Object |
Returns a bounding box for the node including label in the format:
{
top: Number,
left: Number,
right: Number,
bottom: Number
}
These values are in canvas space.
|
getConnectedNodes(String
nodeId )
|
Returns: Array |
Returns an array of nodeIds of the all the nodes that are directly connected to this node. |
getEdges(String
nodeId )
|
Returns: Array |
Returns an array of edgeIds of the edges connected to this node. |
startSimulation() |
Returns: none |
Start the physics simulation. This is normally done whenever needed and is only really useful if you
stop the simulation yourself and wish to continue it afterwards.
|
.
stopSimulation() |
Returns: none |
This stops the physics simulation and triggers a stabilized event. It can be restarted
by
dragging a node, altering the dataset or calling startSimulation() .
|
stabilize() |
Returns: none |
You can manually call stabilize at any time. All the stabilization options above are used. |
getSelection() |
Returns: Object |
Returns an object with selected nodes and edges ids like this:
{
nodes: [Array of selected nodeIds],
edges: [Array of selected edgeIds]
}
|
getSelectedNodes() |
Returns: Array |
Returns an array of selected node ids like so:
[nodeId1, nodeId2, ..] .
|
getSelectedEdges() |
Returns: Array |
Returns an array of selected edge ids like so: [edgeId1, edgeId2, ..] . |
getNodeAt({x: xPosition
DOM, y: yPosition DOM} )
|
Returns: String |
Returns a nodeId or undefined. The DOM positions are expected to be in pixels from the top left
corner
of the canvas.
|
getEdgeAt({x: xPosition
DOM, y: yPosition DOM} )
|
Returns: String |
Returns a edgeId or undefined. The DOM positions are expected to be in pixels from the top left
corner
of the canvas..
|
selectNodes(Array with
nodeIds ,[Boolean
highlightEdges] )
|
Returns: none |
Selects the nodes corresponding to the id's in the input array. If highlightEdges is true or
undefined,
the neighbouring edges will also be selected. This method unselects all other objects before
selecting
its own objects. Does not fire events.
|
selectEdges(Array with
edgeIds )
|
Returns: none |
Selects the edges corresponding to the id's in the input array. This method unselects all other
objects
before selecting its own objects. Does not fire events.
|
unselectAll() |
Returns: none |
Unselect all objects. Does not fire events. |
getScale() |
Returns: Number |
Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.
|
getPosition() |
Returns: Number |
Returns the current central focus point of the camera. |
fit([Object
options] )
|
Returns: none |
Zooms out so all nodes fit on the canvas. You can supply options to customize this:
{
nodes:[Array of nodeIds],
animation: { // -------------------> can be a boolean too!
duration: Number
easingFunction: String
}
}
The nodes can be used to zoom to fit only specific nodes in the view.
The other options are explained in the moveTo() description below.
All options are optional for the fit method.
|
focus(
String nodeId ,
[Object options] )
|
Returns: none |
You can focus on a node with this function. What that means is the view will lock onto that node, if
it
is moving, the view will also move accordingly. If the view is dragged by the user, the focus is
broken.
You can supply options to customize the effect:
{
scale: Number,
offset: {x:Number, y:Number}
locked: boolean
animation: { // -------------------> can be a boolean too!
duration: Number
easingFunction: String
}
}
All options except for locked are explained in the moveTo() description below. Locked
denotes whether or not the view remains locked to the node once the zoom-in animation is finished.
Default value is true. The options object is optional in the focus method.
|
moveTo(Object
options )
|
Returns: none |
You can animate or move the camera using the moveTo method. Options are:
{
position: {x:Number, y:Number},
scale: Number,
offset: {x:Number, y:Number}
animation: { // -------------------> can be a boolean too!
duration: Number
easingFunction: String
}
}
The position (in canvas units!) is the position of the central focus point of the camera.
The scale is the target zoomlevel. Default value is 1.0.
The offset (in DOM units) is how many pixels from the center the view is focussed. Default value is
{x:0,y:0}.
For animation you can either use a Boolean to use it with the default options or disable it or you
can
define the duration (in milliseconds) and easing function manually. Available are:
linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic,
easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint .
You will have to define at least a scale or a position. Otherwise, there is nothing to move
to.
|
releaseNode() |
Returns: none |
Programatically release the focussed node. |
The options object supplied to the cluster functions can contain these properties: