du.widgets.legend

Module implementing a colored legend. A legend is a static label together with a colored square.

Requires: d3@v4 du.Widget

Legend

du.widgets.legend.Legend(name[, parent])

The legend widget class. Legend text is set by the color object passed to the method colors.
argtypedescription
namestringIdentifier of the legend.
parentobjectParent 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.
argtypedescription
keysObject[]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.
returndescription
du.widgets.legend.LegendReference to the current Legend.

twoColumns

du.widgets.legend.Legend.twoColumns(on)

Makes legend two-column wide. Default is false.
argtypedescription
onbooleanWhether legend should be two columned.
returndescription
du.widgets.legend.LegendReference to the current Legend.

highlight

du.widgets.legend.Legend.highlight(key, duration)

Highlights the specified legend.
argtypedescription
keystringLabel of the legend to highlight.
durationnumberDuration of the highlight animation.
returndescription
du.widgets.legend.LegendReference to the current Legend.