Force-directed Node-Link Diagram
This is the Vega Force Directed Layout Example
Vega example
NetPanorama example
Vega specification
Layout algorithm is limited to the force-directed layout provided by d3-force
, though the forces can be customized.
The layout is computed by a transform, which sets a signal; the specification for rendering the links includes "require": {"signal": "force"},
, which implicitly constructs a network such that sourceX
can be set to datum.source.x
.
In contrast, in NetPanorama networks are explicitly constructed, rather than being implicitly constructed as a side-effect of computing a layout, which allows a great deal of control.
The clusters are pre-computed in the dataset: if they were not, there would be no way to do the clustering using Vega.
| |
Define signals, and bid to UI controls that can change them |
|
Load the node and edge data |
|
Define color scale for the nodes |
|
| |
Render nodes |
|
Apply a "force" transform to compute a force-directed layout. |
|
| |
Render links |
|
|
NetPanorama specification
The specification for the rendering of nodes and links is simplified by lifting the construction of the network and the computing of the layout to separate sections of the specification.
| |
define parameters |
|
Load the node and edge data... |
|
...and assemble into a network. |
|
Compute a force directed layout |
|
Define a color scale for the node. |
|
| |
Render the links |
|
Render the nodes |
|
|