Skip to content

Legends

Legends, like axes, are used to display information about a scale. Typically, the term "legend" covers any kind of non-axis graphical hint about a chart's scale and visual encodings.

Ordinal Color Scale Legend

sszvis.legendColorOrdinal

legendColorOrdinal.scale

An ordinal scale which will be transformed into the legend.

legendColorOrdinal.[rowHeight]

The height of the rows of the legend.

legendColorOrdinal.[columnWidth]

The width of the columns of the legend.

legendColorOrdinal.[rows]

The target number of rows for the legend.

legendColorOrdinal.[columns]

The target number of columns for the legend.

legendColorOrdinal.orientation

The orientation (layout order) of the legend. should be either "horizontal" or "vertical".No default.

legendColorOrdinal.[reverse]

Whether to reverse the order that categories appear in the legend. Default false

legendColorOrdinal.[rightAlign]

Whether to right-align the legend. Default false.

legendColorOrdinal.[horizontalFloat]

A true value changes the legend layout to the horizontal float version. Default false.

legendColorOrdinal.[floatPadding]

The amount of padding between elements in the horizontal float layout. Default 10px

legendColorOrdinal.[floatWidth]

The maximum width of the horizontal float layout. Default 600px

Two legends, including one right-aligned

Line Chart — Two-Axis
Loading the chart…

Multiple columns

Stacked Horizontal Bar Chart
Loading the chart…

The horizontal float layout

Grouped Bar Chart — Two Small
Loading the chart…

Linear Color Scale Legend

sszvis.legendColorLinear

legendColorLinear.scale

The scale to use to generate the legend

legendColorLinear.[displayValues]

A list of specific values to display. If not specified, defaults to using scale.ticks

legendColorLinear.[width]

The pixel width of the legend (default 200px)

legendColorLinear.[segments]

The number of segments to aim for. Note, this is only used if displayValues isn't specified, and then it is passed as the argument to scale.ticks for finding the ticks. (default 8)

legendColorLinear.[labelText]

An array of labels for the legend endpoints. If not supplied, defaults to using the first and last tick values. For string labels, name the type: legendColorLinear<string>().

legendColorLinear.[labelFormat]

An optional formatter function for the end labels. Usually should be sszvis.formatNumber.

Example - With custom labels

Map — Schweiz
Loading the chart…

Binned Color Scale Legend

sszvis.legendColorBinned

legendColorBinned.scale

A scale to use to generate the color values

legendColorBinned.[displayValues]

An array of values which should be displayed. Usually these should be the bin edges

legendColorBinned.[endpoints]

The endpoints of the scale (note that these are not necessarily the first and last bin edges). These will become labels at either end of the legend.

legendColorBinned.[width]

The pixel width of the legend. Default 200

legendColorBinned.[labelFormat]

A formatter function for the labels of the displayValues.

Example

Heat Table — Wer mit wem?
Loading the chart…

Variable Radius Legend

sszvis.legendRadius

legendRadius.scale

A scale to use to generate the radius sizes

legendRadius.[fill]

A function or string that gives a fill color for the demonstration circles (default white)

legendRadius.[stroke]

A function or string that gives a stroke color for the demonstration circles (default black)

legendRadius.[strokeWidth]

A number or function that gives a stroke width for the demonstration circles (default 1.25)

legendRadius.[labelFormat]

Formatter function for the labels

Example

Scatterplot — Variable Radius
Loading the chart…