du.widgets.multibarchart

Module implementing an interactive multi-plot bar chart.

Requires: d3@v4 du.Widget

MultiBarChart

du.widgets.multibarchart.MultiBarChart(name[, parent])

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

barWidth

du.widgets.multibarchart.MultiBarChart.barWidth(barWidth)

Sets the total bar width (all plots together) relative to the default. Default is an almost tight-packed bar chart.
argtypedescription
barWidthbooleanThe bar width relative to the default.
returndescription
du.widgets.multibarchart.MultiBarChartReference to the current BarChart.

sortByX

du.widgets.multibarchart.MultiBarChart.sortByX(sort)

Enables sorting of data by the X axis. Default is false.
argtypedescription
sortbooleanWhether to sort data by the X values.
returndescription
du.widgets.multibarchart.MultiBarChartReference to the current BarChart.

xDomain

du.widgets.multibarchart.MultiBarChart.xDomain(domain)

Sets X domain for the multi bar chart. The order of the values specified in the domain are used to sort the data in the chart. Default is off.
argtypedescription
domainnumber[] string[]Array containing the domain values.
returndescription
du.widgets.multibarchart.MultiBarChartReference to the current BarChart.

data

du.widgets.multibarchart.MultiBarChart.data(data)

Binds data to the bar chart. 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. Note that the data is sorted by the X values assuming they are strings.
argtypedescription
dataobjectData to plot.
returndescription
du.widgets.multibarchart.MultiBarChartReference to the current BarChart.

highlight

du.widgets.multibarchart.MultiBarChart.highlight(key, duration)

Highlights the specified plot.
argtypedescription
keystring string[]Single key or an array of keys of the bar(s) to highlight.
durationnumberDuration of the highlight animation.
returndescription
du.widgets.multibarchart.MultiBarChartReference to the current BarChart.

highlightRange

du.widgets.multibarchart.MultiBarChart.highlightRange(range, duration)

Highlights the sepcified range.
argtypedescription
rangenumber[]Array containing the lower and upper boundary of the range to highlight.
durationnumberDuration of the highlight animation. nullable
returndescription
du.widgets.multibarchart.MultiBarChartReference to the current BarChart.

addMarker

du.widgets.multibarchart.MultiBarChart.addMarker(id, value, label, pos, color, anchor)

Adds a marker to the chart. A marker is a horizontal line with a label. If a marker with the specified identifier already exists, the marker is ignored.
argtypedescription
idstringMarker identifier.
valuenumber stringY value (height) of the marker line.
labelstringLabel of the marker.
posstringPosition of the label relative to the marker line. Default is 0.
colorstringColor of the marker. Default is the font color.
anchorstringText anchor. Supported values: start, middle, right. Default is start.
returndescription
objectD3 selection of the marker if it could be added, null otherwise.

removeMarker

du.widgets.multibarchart.MultiBarChart.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.