du.widgets.legend
Module implementing a colored legend. A legend is a static label together with a colored square.Requires:
d3@v4 du.WidgetLegend
du.widgets.legend.Legend(name[, parent])
The legend widget class. Legend text is set by the color object passed to the method
colors.
| arg | type | description |
|---|---|---|
| name | string | Identifier of the legend. |
| parent | object | Parent element to append widget to. If not specified, widget is appended to body. optional |
labels
du.widgets.legend.Legend.labels(keys)
Sets the labels for the legend entries.
| arg | type | description |
|---|---|---|
| keys | Object[] | Array of objects containing a key and a text propert for the specific key. The key is used to assign the label to a color. The order of the labels is used when the legend is built. If text is not specified, the label key is used as text. |
| return | description |
|---|---|
du.widgets.legend.Legend | Reference to the current Legend. |
twoColumns
du.widgets.legend.Legend.twoColumns(on)
Makes legend two-column wide. Default is false.
| arg | type | description |
|---|---|---|
| on | boolean | Whether legend should be two columned. |
| return | description |
|---|---|
du.widgets.legend.Legend | Reference to the current Legend. |
highlight
du.widgets.legend.Legend.highlight(key, duration)
Highlights the specified legend.
| arg | type | description |
|---|---|---|
| key | string | Label of the legend to highlight. |
| duration | number | Duration of the highlight animation. |
| return | description |
|---|---|
du.widgets.legend.Legend | Reference to the current Legend. |