du.widgets.barchart

Module implementing an interactive bar chart.

Requires: d3@v4 du.Widget

BarChart

du.widgets.barchart.BarChart(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

vertical

du.widgets.barchart.BarChart.vertical(vertical)

Makes the bar chart vertical, effectively swapping the axes. Default is false.
argtypedescription
verticalbooleanWhether to set bar chart to vertical.
returndescription
du.widgets.barchart.BarChartReference to the current BarChart.

xDomain

du.widgets.barchart.BarChart.xDomain(domain)

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

corners

du.widgets.barchart.BarChart.corners(radius)

Adds rounded corners to the bars. Default is 0.
argtypedescription
radiusnumberCorner radius to use.
returndescription
du.widgets.barchart.BarChartReference to the current BarChart.

values

du.widgets.barchart.BarChart.values(on)

Adds values as indicative numbers on the bars. Default is false.
argtypedescription
onbooleanWhether to add indicative numbers on the bars.
returndescription
du.widgets.barchart.BarChartReference to the current BarChart.

valueFormat

du.widgets.barchart.BarChart.valueFormat(format)

Sets the formatter for the bar values. Default is just the value itself.
argtypedescription
formatFunctionThe formatter function to use.
returndescription
du.widgets.barchart.BarChartReference to the current BarChart.

data

du.widgets.barchart.BarChart.data(data)

Binds data to the bar chart. Expected data format: array of objects with properties name (name of the bar) and value (corresponding number).
argtypedescription
dataobjectData to plot.
returndescription
du.widgets.barchart.BarChartReference to the current BarChart.

highlight

du.widgets.barchart.BarChart.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.barchart.BarChartReference to the current BarChart.