Network - selection

Handles the selection of nodes and edges.

Options

The options for the selection have to be contained in an object titled 'selection'.

Click on the options shown to show how these options are supposed to be used.


All of the individual options are explained here:

nametypedefaultdescription
select BooleantrueWhen true, the nodes and edges can be selected by the user.
selectConnectedEdges BooleantrueWhen true, on selecting a node, its connecting edges are highlighted.

Methods

This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.

namereturnsdescription
getSelection()
{
  nodes: [Array of selected nodeIds],
  edges: [Array of selected edgeIds]
}
Returns an object with selected nodes and edges ids.
getSelectedNodes() [nodeId1, nodeId2, ..]Returns an array of selected node ids.
getSelectedEdges() [edgeId1, edgeId2, ..]Returns an array of selected edge ids.
getNodeAt(
   {x: xPosition DOM,
   y: yPosition DOM}

)
nodeIdReturns 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}

)
edgeIdReturns 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]
)
noneSelects 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
)
noneSelects 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() none Unselect all objects. Does not fire events.

Events

The selection handler does not fire events. All related events are fired by the interaction module because they are triggered by user interaction.