Newton Graph Library

Newton Graph Library

Class

Nodes

Extends

Encapsulates what is needed to create the nodes of a network graph, namely rendering, positioning and animation of nodes based on data.

Constructor

new Nodes(options)

Parameters

  • options Object

    Properties

    • dom String <optional>
      window.document

      DOM reference, required for testing

    • container String <optional>

      HTML identifier used by for d3

Source

Methods

bindGraph(graph)

Binds this view to a graph so we can react to changes and re-render and adjust the graph as necessary.

Parameters

  • graph Graph

    graph to listen to for changes

Overrides

Source

Events

click

Note: this is a custom event and not a browser event.

Type

Example

nodes.on('click', (node) => {
	console.log('User clicked on node ' + node.name)
})

Listeners of this event

enter

An Array of enter Nodes, i.e. new nodes per d3.js general update pattern.

Type

  • Array

Listeners of this event

exit

An Array of exiting Nodes, i.e. nodes to be removed per d3.js general update pattern.

Type

  • Array

Listeners of this event

mouseout

Note: this is a custom event and not a browser event.

Type

Example

nodes.on('mouseout', (node) => {
	console.log('mouse left node ' + node.name)
})

Listeners of this event

mouseover

Note: this is a custom event and not a browser event.

Type

Example

nodes.on('mouseover', (node) => {
	console.log('User hovered on node ' + node.name)
})

Listeners of this event

update

An Array of combined existing and new Nodes, per d3.js general update pattern.

Type

  • Array

Listeners of this event