Constructor
new View(options)
Parameters
-
options
Object
Properties
-
dom
String
<optional>
window.documentDOM reference, required for testing
-
container
String
<optional>
HTML identifier used by for d3
-
dom
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
-
node
Node
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:
- d3.js's
data()
method returns all changed nodes - Remove deleted elements via
exit().remove()
- Add new elements via
enter()
- 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
-
nodes
Source
resetStyles()
Reset all styles, e.g. colors and visibility
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
-
node
Node