Arc Diagram
Vega Arc Diagram Example
Vega example
NetPanorama example
Vega specification
This example feels awkward, due to the absence of semantic concepts that are present in NetPanorama:
With no concept of a network and network transform, there is no transform to calculate the node degree directly. Instead, a series of tabular transforms are used: 2 construct separate tables recording node in/out-degrees, and then a series of 4 transforms to combine these into an undirected degree to be saved as an attribute of the nodes. This approach is both awkward and brittle: it would be impossible to replace the degree with an alternative metric such as betweeness centrality.
With no concept of a layout, the example instead creates symbol
marks that are made invisible by setting their opacity
to 0
.
This approach only works for layouts where the x
and y
coordinates of entries can be easily obtained by directly applying an expression or scale.
The specification of arcs is also complicated: with no concept of a network, the specification must apply a pair of transforms: 1 to find the source and target nodes of each edge, and 1 to obtain their coordinates.
| |
import edges data, as would be done in NetPanorama |
|
Construct separate tables recording node in/out-degrees, by aggregating rows of the link table using a COUNT operation. |
|
Load the node data... |
|
...and save the degree as a field by applying a sequence of 4 transforms. |
|
| |
Define a band scale that positions nodes. |
|
Define a scale for node color. |
|
| |
Fake a "layout" by drawing symbols with opacity 0, positioned using the position scale. |
|
Draw the arcs. |
|
Draw a circular mark for each label. |
|
Draw label for each node. |
|
NetPanorama specification
The equivalent NetPanorama code is more explicit.
We begin by loading tabular data in the same way, but perform some additional steps:
- assembling the data into a network: this allows the source and target nodes of an edge to be accessed.
- defining an ordering for the nodes
- constructing a layout
This may seem to introduce complexity, but it provides two main benefitS:
- it simplifies subsequent stages (such as calculating node metrics and rendering edges);
- it provides additional flexibility (e.g., to calculate a different node metric, or change the ordering)
| |
Load the data |
|
Join the node and link tables to construct a network. |
|
Define scales to set node sizes and colors. |
|
Define an ordering for the nodes... |
|
...and use this to construct and layout. |
|
| |
Draw the arcs. |
|
Draw a circle for each node. |
|
Write the name for each node. |
|
|