Module implementing an interactive bar chart.
Requires: d3@v4 du.Widget
du.widgets.barchart.BarChart(name[, parent])
The bar chart widget class.
| arg | type | description |
|---|
| name | string | Identifier of the widget. |
| parent | object | Parent element to append widget to. If not specified, widget is appended to body. optional |
du.widgets.barchart.BarChart.vertical(vertical)
Makes the bar chart vertical, effectively swapping the axes. Default is false.
| arg | type | description |
|---|
| vertical | boolean | Whether to set bar chart to vertical. |
| return | description |
|---|
du.widgets.barchart.BarChart | Reference 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.
| arg | type | description |
|---|
| domain | number[] string[] | Array containing the domain values. |
| return | description |
|---|
du.widgets.barchart.BarChart | Reference to the current BarChart. |
du.widgets.barchart.BarChart.corners(radius)
Adds rounded corners to the bars. Default is 0.
| arg | type | description |
|---|
| radius | number | Corner radius to use. |
| return | description |
|---|
du.widgets.barchart.BarChart | Reference to the current BarChart. |
du.widgets.barchart.BarChart.values(on)
Adds values as indicative numbers on the bars. Default is false.
| arg | type | description |
|---|
| on | boolean | Whether to add indicative numbers on the bars. |
| return | description |
|---|
du.widgets.barchart.BarChart | Reference to the current BarChart. |
du.widgets.barchart.BarChart.valueFormat(format)
Sets the formatter for the bar values. Default is just the value itself.
| arg | type | description |
|---|
| format | Function | The formatter function to use. |
| return | description |
|---|
du.widgets.barchart.BarChart | Reference to the current BarChart. |
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).
| arg | type | description |
|---|
| data | object | Data to plot. |
| return | description |
|---|
du.widgets.barchart.BarChart | Reference to the current BarChart. |
du.widgets.barchart.BarChart.highlight(key, duration)
Highlights the specified plot.
| arg | type | description |
|---|
| key | string string[] | Single key or an array of keys of the bar(s) to highlight. |
| duration | number | Duration of the highlight animation. |
| return | description |
|---|
du.widgets.barchart.BarChart | Reference to the current BarChart. |