du.widgets.linechart

Module implementing a line chart.

Requires: d3@v4 du.Widget

LineChart

du.widgets.linechart.LineChart(name[, parent])

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

xMin

du.widgets.linechart.LineChart.xMin(value)

Sets the lower boundary for the X axis.
argtypedescription
valuenumberThe value of the lower boundary.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

xMax

du.widgets.linechart.LineChart.xMax(value)

Sets the upper boundary for the X axis.
argtypedescription
valuenumberThe value of the upper boundary.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

xType

du.widgets.linechart.LineChart.xType(type)

Sets the type of the X axis. Supported values are: number, time, string. Default is number.
argtypedescription
typestringType of the X axis.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

lineStyles

du.widgets.linechart.LineChart.lineStyles(style)

Sets line styles for each plot.
argtypedescription
styleObjectObject containing the style for each plot. A style is an object with SVG styles to set. Currently only stroke-dasharray is supported.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

smooth

du.widgets.linechart.LineChart.smooth(on)

Adds smoothing to the curves and error bands. Smoothing is done by using Catmull-Rom splines for each curve. Default is false.
argtypedescription
onbooleanWhether to add smoothing to the curves.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

dots

du.widgets.linechart.LineChart.dots(on)

Adds dots to the lines at each data point. Default value is false.
argtypedescription
onbooleanWhether to add dots to the lines.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

data

du.widgets.linechart.LineChart.data(data)

Binds data to the line plot. Expected data format: array containing an object for each plot. A plot object has a name property with the name of the plot and a values property which is the array of (x, y) coordinates. Each data point can have two optional values lo, hi representing the error of the y value. Default values of lo and hi for all data points are 0. All plots are sorted by their x values before plot.
argtypedescription
dataArrayData to plot.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

highlight

du.widgets.linechart.LineChart.highlight(key, duration)

Highlights the specified plot.
argtypedescription
keystring string[]Single key or an array of keys of the line(s) to highlight.
durationnumberDuration of the highlight animation.
returndescription
du.widgets.linechart.LineChartReference to the current LineChart.

addMarker

du.widgets.linechart.LineChart.addMarker(id, key, start, end, label)

Adds a marker to the specified line. A marker is a text along with a 90-degree angle connecting two points of a line. If a marker with the specified identifier already exists, the marker is ignored.
argtypedescription
idstringMarker identifier.
keystringKey of the line to mark.
startnumber stringStart X position of the marker.
endnumber stringEnd X position of the marker.
labelstringLabel of the marker.
returndescription
objectD3 selection of the marker if it could be added, null otherwise.

removeMarker

du.widgets.linechart.LineChart.removeMarker(id)

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

addPin

du.widgets.linechart.LineChart.addPin(id, pos, color, size, height)

Adds a pin to the specified line. A pin is a vertical line with a circle on top denoting a specific location in the chart. If a pin with the specified identifier already exists, the pin is ignored.
argtypedescription
idstringPin identifier.
posnumber stringPin position on the X axis.
colorstringPin color. Defaults to font color.
sizestringPin head radius. Default is 4 pixels.
heightstringHeight of the pin relative to the vertical range. Defaults to 1.
returndescription
objectD3 selection of the pin if it could be added, null otherwise.

removePin

du.widgets.linechart.LineChart.removePin(id)

Removes a pin from the plot.
argtypedescription
idstringIdentifier of the pin to remove.
returndescription
booleanTrue if pin exists and could be removed, false otherwise.