du.widgets.trajectoryplot

Module implementing a trajectory plot. A trajectory plot is a two dimensional chart showing the sequence of positions for an object moving in time.

Requires: d3@v4 du.Widget

TrajectoryPlot

du.widgets.trajectoryplot.TrajectoryPlot(name[, parent])

The trajectory plot widget class.
argtypedescription
namestringIdentifier of the widget.
parentobjectParent element to append widget to. If not specified, widget is appended to body. optional

boundary

du.widgets.trajectoryplot.TrajectoryPlot.boundary(dim)

Sets the boundary of the area for the trajectories. Default is [0, 1, 0, 1].
argtypedescription
dimnumber[]Array containing the minimum and maximum of the x and y coordinates in the following order: [xmin, xmax, ymin, ymax]. t
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

maxLength

du.widgets.trajectoryplot.TrajectoryPlot.maxLength(length)

Sets the maximum trajectory length to the specified value. Default is 10.
argtypedescription
lengthnumberThe number of historical positions to show.
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

fadeExp

du.widgets.trajectoryplot.TrajectoryPlot.fadeExp(exponent)

Sets the fading exponent for the exponential fade-out of trajectories. Opacity of each trajectory segment and stop position is calculated as exp(-tau * t), where t denotes the age of the segment (relative to the age of the whole trajectory, so it is bounded in [0, 1]), and tau is the exponent. Default is 0.
argtypedescription
exponentnumberExponent to set for trajectory fading out.
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

animate

du.widgets.trajectoryplot.TrajectoryPlot.animate(on)

Enables animation. Default is false.
argtypedescription
onbooleanWhether animation should be enabled or not.
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

showHead

du.widgets.trajectoryplot.TrajectoryPlot.showHead(show)

Shows current position of the entity. Default is false.
argtypedescription
showbooleanWhether current position should be shown.
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

background

du.widgets.trajectoryplot.TrajectoryPlot.background(options)

Adds an image to the background of the trajectory plot. Note that the image is scaled up to fit the plot. Default is empty.
argtypedescription
optionsObjectObject containing the background options. The following properties are supported:
  • path: Path to the image file.
  • opacity: Background opacity. Default is 1.
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

data

du.widgets.trajectoryplot.TrajectoryPlot.data(data)

Binds data to the trajectory plot. Expected data format: array of objects with two properties: name which is the name of the trajectory and values which is an array containing (t, x, y) objects for the trajectory points. The property t denotes the time of the position and each trajectory is sorted according to that value in ascending order (so t should have properly sortable values).
argtypedescription
dataArrayData to plot.
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

highlight

du.widgets.trajectoryplot.TrajectoryPlot.highlight(key, duration)

Highlights the specified trajectory.
argtypedescription
keystring string[]Single key or an array of keys of the dot group(s) to highlight.
durationnumberDuration of the highlight animation.
returndescription
du.widgets.trajectoryplot.TrajectoryPlotReference to the current TrajectoryPlot.

addMarker

du.widgets.trajectoryplot.TrajectoryPlot.addMarker(name, key, pos, size, info)

Adds a marker to the plot. A marker is a dot along with some data that is used to show on tooltips. If a marker with the specified identifier already exists, the marker is ignored.
argtypedescription
namestringName of the marker.
keystringKey of the line to mark.
posnumber[]Array containing the x and y coordinates of the marker.
sizenumberDiameter of the marker.
infoObjectObject containing the title and content for the marker's tooltip.
returndescription
ObjectD3 selection of the marker if it could be added, null otherwise.

removeMarker

du.widgets.trajectoryplot.TrajectoryPlot.removeMarker(name)

Removes a marker from the plot.
argtypedescription
namestringName of the marker to remove.
returndescription
booleanTrue if marker existed and could be removed, false otherwise.

getMarkers

du.widgets.trajectoryplot.TrajectoryPlot.getMarkers()

Returns the name of all markers.
returndescription
string[]Array containing all marker names.