Module

legends

Methods

# static prepareLegends(legends, palettes, columnInfo)

Validate user-provided legend options and prepare legends for rendering. A legend is necessary for each palette used in the visualization. If user have not provided legend configuration for a palette that is used in ColumnInfo, it will be added automatically.

Parameters:
Name Type Description
legends Array.<module:legends~LegendInfo>

user provided legend configuration

palettes module:palettes~PaletteMapping

mapping of names to palette colors

columnInfo Array.<module:columns.Column>

user provided information on columns

View Source legends.js, line 41

Type Definitions

Object

# LegendInfo

Legend configuration

Properties:
Name Type Description
title string

title of the legend, defaults to palette name

palette string

name of the palette to use

geom string

type of geom to use for legend. If absent, will be copied from the first column info with the same palette

labels Array.<string>

labels for the legend. Required for text and image geoms. For image geom is a list of captions for the images. For text geom is a list of texts displayed on the left of the legend. For pie geom can be inferred from palette, if palette is specified as a CustomPalette. For numeric geoms defaults to ['0', '', '0.2', '', '0.4', '', '0.6', '', '0.8', '', '1']

label_align 'left' | 'center' | 'right'

alignment of the labels. Defaults to center for circle, rect and funkyrect geoms

label_hjust number

numerical alias for label_align, converts 0, 0.5, 1 to left, center, right, complains about any other values

size number | Array.<number>

size of the legend elements. Required for image geom, will set the width of the image. For circle and funkyrect geoms defaults to increasing values from 0 to 1. For rect and bar geoms defaults to 1. Must be the same length as labels

values number | Array.<number>

values for the legend elements. For numeric geoms represents color values for the legend elements. Must be the same length as labels. Required for image and text geoms. For image geom is a list of image URLs. For text geom is a list of texts displayed on the right of the legend

View Source legends.js, line 5