Newton Graph Library

Newton Graph Library

Class

Graph

The Graph class holds everything together: Nodes, Links, Labels and the Network.

Constructor

new Graph(opts)

Note that the opts.network attribute is required.

Parameters

  • opts Object {}

    Properties

    • margin Number <optional>
      40

      Graph margins in pixels.

    • height Number <optional>
      550

      Height of network graph in pixels.

    • width Number <optional>
      800

      Width of network graph in pixels.

    • network Network
    • engine String <optional>
      'cola'

      Force layout engine. Can be d3 or cola.

    • flow String <optional>

      Display links in horizontal flow?

    • draggable Boolean <optional>

      Make nodes draggable?

Source

Properties

  • labels Labels

    reference to Labels used for UI interactions

  • links Links

    reference to Links used for UI interactions

  • nodes Nodes

    reference to Nodes used for UI interactions

  • renders Integer

    internal counter used to help decide whether to re-render a layout

Methods

highlightDependencies(node, optionsopt)

Highlights dependencies, of nodes

Parameters

  • node Node

    Node, whose dependencies are to be highlighted

  • options Object <optional>
    {}

    Properties

    • arrows Boolean <optional>
      null

      Show directional arrows of source-target relationship?

Source

render(dataopt)

Renders Nodes, Links and Labels for a Graph. If nodes have failures, they will be highlighted with colors and animations in the graph.

Parameters

  • data Object <optional>

    Defaults to graph's Network data.

Source

Events

node:click

Type

Example

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

node:mouseout

Type

Example

graph.on('node:mouseout', (node) => {
	console.log('User mouse-outed on node ' + node.name)
})

node:mouseover

Type

Example

graph.on('node:mouseover', (node) => {
	console.log('User mouse-overed on node ' + node.name)
})