Skip to main content

Interaction

NetPanorama supports interactivity by allowing users to define parameters whose values are updated by interactions, and by using these parameters to update visualization.

It supports two main types of parameters:

  • Variable parameters, which can be updated by UI controls such as sliders or checkboxes.
  • Selection parameters, which can be updated by clicking on elements, using a rectangular brush, or making a lasso selection

Interaction without parameters

Some forms of interaction occur directly, without adjusting the value of intermediate parameters.

To disambiguate between multiple interactions that involve the cursor, you can specify a list of modifier keys that must be held down during an interaction (modifierKeyRequired) and/or keys that must not be held down (modifierKeyAbsent).

Tooltips

Mousing-over an element can display text in a tooltip.

The contents of the tooltip are set by the tooltip attribute on the mark, which can be either a field-name or an expression.

{
"entries": "net.nodes",
"layout": "net-layout",
"mark": {
"type": "circle",
"area": 70,
"fill": "steelblue",
"tooltip": { "field": "label" }
}
}
    {
"entries": "le-mis-network.links",
"layout": "l",
"mark": {
"type": "square",
"size": 100,
"fill": {"expression": "datum.source.id < datum.target.id ? 'red' : 'blue' " },
"tooltip": {"expression": "datum.target.name + '<-->' + datum.source.name "}

}
}

Dragging to re-position nodes

For example, if the positions of elements were determined by a layout, then they can be made draggable such that dragging them with a mouse directly updates the underlying layout.

    {
"entries": "le-mis-network.nodes",
"layout": "le-mis-layout",
"actions": [
{ "interaction": "drag" }
],
"mark": {
"type": "circle",
"area": { "field": "degree", "scale": "radius" },
"fill": { "field": "degree", "scale": "color" }
}
}

Panning and zooming

Adding a zoom attribute to the top-level of the specification enables zooming. A zoom object can also have optional min: number and/or max: number attributes to specify the minimum and maximum scaling factor possible.

Adding a pan attribute to the top-level of the specification enables panning. A pan object can also have optional min: [number, number] and/or max: [number, number] attributes to specify the minimum and maximum x,y panning values.

Fixing coordinates

Any mark or layout specification can also be given a fixPanZoom: "x" | "y" | "both" attribute to fix the x, y or both coordinates of a group of mark.

Variable parameters

Variable parameters can be bound to UI controls.

note

The scope of places where parameters can be used will be increased.

Their values can then be used to set properties.

  "parameters": [
{
"name": "r",
"bind": {
"input": "range",
"label": "Size",
"min": "20",
"max": "400",
"step": "2"
}
},
{
"name": "color",
"bind": {
"input": "color",
"label": "Color",
"value": "#ef2929"
}
}
],
AttributeTypeDescription
namestringThe name of the parameter.
value?anyThe default vale of the parameter.
bind?BindingBinds the parameter to an input element.
animate?AnimationSpecification for how the parameter should be animated.

Binding to UI Elements

Binding a parameter to a UI element allows a user to update the parameter's value by interacting with a control such as a slider or selection box.

AttributeTypeDescription
input?"checkbox" or "radio" or "range" or "select"The type of input element to use.
element?stringAn optional CSS selector string indicating the parent element to which the input element should be added.
label?stringLabel to use for the input element (by default, the name of the bound signal will be used).
astringValues for attributes to set on the HTML element.

Additional attributes for a radio or selection box:

AttributeTypeDescription
input"radio" or "selection"
optionsany[]Array of the available options.
labels?string[]Array containing labels for the options. By default, the label is the obtained by converting the option value to a string.

options???

Additional attributes for a range input:

AttributeTypeDescription
input"range"
max?numberMaximum slider value. Defaults to 100 (or the default signal value, if that is larger).
min?numberThe minimum slider value. Defaults to 0 (or the default signal value, if that is smaller).
step?numberThe minimum slider increment.

Additional attributes for binding to a pre-existing HTML control (not created by NetPanorama):

AttributeTypeDescription
inputundefined
elementstringCSS selector for an input element.
event?stringThe name of the event to listen for (default is oninput).
event?stringThe name of the event to listen for (default is oninput).

It is also possible to bind a parameter to the range of a brush draw on an axis. For example, this can be used to allow a brushing interaction to filter nodes based on their degree. In order to determine the scale for this axis, it is necessary to specify which network is to be filtered, whether nodes or links are to be filtered, and which field wll be filtered on.

AttributeTypeDescription
axisType"linear" or "time"
networkstringName of the network to be filtered.
for"nodes" or "links"Whether this control will be used to filter nodes or edges.
fieldstringThe field on the node or link to be filtered.
updateContinuously?booleanIf set to true, parameter will be updated continuously as the brush is moved, without waiting for interaction to end.
updateContinuously?booleanIf set to true, parameter will be updated continuously as the brush is moved, without waiting for interaction to end.

Animation

It is possible to animate between successive values of a parameter. Note that NetPanorama currently re-renders for each new parameter frame, rather than smoothly interpolating.

AttributeTypeDescription
label?stringLabel displayed by animation controls (by default, the name of the parameter will be used)
minnumberMinimum values for the animation
maxnumberMaximum value for the animation.
values(string or number)[]Array of discrete values to transition between.
stepTime?numberTime, in seconds, between updates to the parameter's value. Incompatible with totalTime option.
totalTime?numberTime taken for a complete cycle of the animation. Incompatible with stepTime option.
stepSize?numberValue by which the parameter should be increased on each update. Incompatible with the numSteps option.
numSteps?numberTotal number of updates in one cycle of the animation. Incompatible with the stepSize option.
autoStart?booleanIf true, the animation will start automatically; if false, animation will not start until the pay button is pressed.
loop?booleanIf true, the animation will loop: after reaching the max value, the parameter wil reset to the min value and begin increasing again.
showPauseControl?booleanIf true, display a play/pause button.
showStepControl?booleanIf true, display a button that allows users to step the next/previous state of the animation.
showJumpControl?booleanIf true, display a button allowing users to jump to the first/last state of the animation.
showValue?booleanIf true, display the current value of the parameter.
showValue?booleanIf true, display the current value of the parameter.

Selection parameters

Selection parameters contain a set of nodes and a set of edges.

They can be updated by interacting with a visualization. Optionally, dragging can reposition all selected nodes simultaneously.

Specifically, you can define actions that update a selection (by adding elements, removing elements, toggling whether elements are present, or replacing the elements in the selection), in response to a specific type of interaction (clicking on an element, using a rectangular brush, or making a lasso selection), when certain modifier keys are held down and others are not.

Selection definitions

Selections are defined in the selections attribute of the top-level of the specification.

AttributeTypeDescription
namestringName of the selection parameter.
value?string[]Initial value of selection.
type"selection"Initial value of selection.
networkstringName of the corresponding network.
dragging?DraggingIf set, then dragging whilst holding down these keys will move the selected nodes.
clearOnBackgroundClickBooleanIf true, then clicking on the background will clear the current selection.

Dragging:

AttributeTypeDescription
modifierKeyRequired?ModifierKeys[]Key that must be held down whilst the interaction occurs (default is "any").
modifierKeyAbsent?ModifierKeys[]Key that must be not held down whilst the interaction occurs (default is none).

Interaction definitions

The interactions that modify selections (like interactions that allow dragging) are defined in the actions attribute of the vis block that defines the visual marks to which they apply.

AttributeTypeDescription
interaction"select"
event?"click" or "mouseenter" or "mouseleave" or "mouseover" or "mouseout"The type of event that triggers this interaction (default is "click").
using?"rect" or "lasso" or "cursor"The interaction type to be handled.
selectionstringThe name of the selection to update
action"add" or "remove" or "replace" or "toggle"How to update the selection (default is "replace")
modifierKeyRequired?ModifierKeys[]Key that must be held down whilst the interaction occurs (default is "any").
modifierKeyAbsent?ModifierKeys[]Key that must be not held down whilst the interaction occurs (default is "any").
modifierKeyAbsent?ModifierKeys[]Key that must be not held down whilst the interaction occurs (default is "any").

A ModifierKeys is one of "alt", "ctrl", "meta" (i.e., the Apple or Window key on a keyboard), "shift".

Derived selections

A selection may be transformed to give a new, derived, selection (e.g., by selecting the neighbours of selected nodes).

AttributeTypeDescription
namestringName of the derived selection.
sourcestringName of the selection from this selection is derived.
transformSelectionTransform[]List of selections that will be applied to the source selection to obtain this selection.

Transformations

As well as the individual attributes listed below, all transformations also have an action attribute that can be either "add" or "replace", depending on whether or not their output should include the original nodes and edges.

Shortest Path

Find the shortest path between a selection containing a pair of nodes (if the selection contains more than 2 nodes, the path is found between the first 2 nodes, and the remained are ignored).If selection contains more than 2 nodes, it will find the shortest path between all pairs of nodes.

AttributeTypeDescription
type"shortestPath"
weight?stringField name containing the edge weight (this could be pre-computed with a calculate transform).As we use Dijiska's algorithm, all weights must be positive.

Prune

Find the shortest path between a selection containing a pair of nodes (if the selection contains more than 2 nodes, the path is found between the first 2 nodes, and the remained are ignored).If selection contains more than 2 nodes, it will find the shortest path between all pairs of nodes.

AttributeTypeDescription
type"prune"
remove"roots" or "leaves" or "isolated"Specifies whether to remove nodes with no incoming connections ("roots"), nodes with no outgoing connections ("leaves")or no connections at all ("isolated").

Filter

Filter (either nodes or edges) retaining only those for which the expression is true.

AttributeTypeDescription
type"filter"
affects"nodes" or "edges"Whether the filter expression applies to nodes or edges.
expressionstringThe expression to evaluate for each edge.

Project

Given a selection, make a new selection containing elements for which the specified fields hae the same values.

AttributeTypeDescription
type"project"
affects"nodes" or "edges".Whether the operation applies to nodes or edges.
fieldsstring[]List of fields to match on.
semantics?"separate" or "combined"If selection contains "red cars" and "blue bikes", should we also select "red bikes" and "blue cars"?

Parallel Edges

Select edges with the same source and target nodes as edges in a selection.

AttributeTypeDescription
type"parallelEdges"
ignoreDirection?booleanSelect edges with the same source and target nodes as edges in a selection.

Common Neighbours

Select the nodes connected to all the nodes in a selection.

AttributeTypeDescription
type"commonNeighbours"
direction"source" or "target" or "both"Select the nodes connected to all the nodes in a selection.

Connected Nodes

Select the nodes connected to a set of edges.

AttributeTypeDescription
type"connectedNodes"
direction"source" or "target" or "both"Select the nodes connected to a set of edges.

Connected Edges

Select the edges connected to a set of nodes.

AttributeTypeDescription
type"connectedEdges"
direction"source" or "target" or "both"Select the edges connected to a set of nodes.

Edges Between

Find the edges joining nodes in one selection with nodes in a second selection.

AttributeTypeDescription
type"connectedEdges"
secondSelectionstringFind the edges joining nodes in one selection with nodes in a second selection.
ignoreDirection?booleanFind the edges joining nodes in one selection with nodes in a second selection.

Neghbours

Find the neighbours of a node (or set of nodes)

AttributeTypeDescription
type"neighbours"
direction"in" or "out" or "both"Find the neighbours of a node (or set of nodes)
depth?number or "infinity"default 1
depth?number or "infinity"default 1