Newton Graph Library

Newton Graph Library

Class

View

Base Class to force interface to be implemented

Constructor

new View(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

Source

hideUnrelated(node)

Visually hides elements unrelated to node parameter. CSS styling is based on data-hidden attribute set on the DOM element.

Parameters

Source

position()

Re-calculates and repositions elements using current data. This is used by the webcola layout adapter for "less noisy" network visualizations.

Source

render(data)

Renders all elements, including related transitions and animations based on data parameters, which should be references to real time data.

Each render() executes method chains that follow the d3.js General Update Pattern:

  1. d3.js's data() method returns all changed nodes
  2. Remove deleted elements via exit().remove()
  3. Add new elements via enter()
  4. Apply styles and UI to all new and existing elements via merge()

This method also stores references to generated elements to the instance for re-positioning by layout adapter.

Lastly, this method is meant to be a callback listener to an event, although it can be called directly.

Parameters

  • data Object

    Properties

    • nodes Array
    • links Array

Source

setRelationships(node)

Classifies elements based on relationship to node parameter. CSS styling is based on data-rel attribute set on the DOM element.

Parameters

Source