Class: LegendHelper

LegendHelper(tableColumn, tableStyleopt, regionProvideropt, nameopt)

new LegendHelper(tableColumn, tableStyleopt, regionProvideropt, nameopt)

Legends for table columns depend on both the table style and the selected column. This class brings the two together to generate a legend. Its key output is legendUrl.

Parameters:
Name Type Attributes Description
tableColumn TableColumn

The column whose values inform the legend.

tableStyle TableStyle <optional>

The styling for the table.

regionProvider RegionProvider <optional>

The region provider, if region mapped. Used if no table column set.

name String <optional>

A name used in the legend if no active column is selected.

Source:

Methods

getColorArrayFromValue(valueopt) → {Array.<Number>}

Maps an absolute value to a color array, based on the legend.

Parameters:
Name Type Attributes Description
value Number <optional>

The absolute value.

Source:
Returns:

The color, as an array [r, g, b, a]. If there is no table column selected, use a random colour. If the value is null, use the nullColor. If no value is provided, or no color bins are defined, use the nullColor.

Type
Array.<Number>

getColorFromValue(valueopt) → {Color}

Maps an absolute value to a Color, based on the legend.

Parameters:
Name Type Attributes Description
value Number <optional>

The absolute value.

Source:
Returns:

The color. If no value is provided, uses a default color.

Type
Color

getScaleFromValue(valueopt) → {Number}

Maps an absolute value to a scale, based on tableColumnStyle.

Parameters:
Name Type Attributes Description
value Number <optional>

The absolute value.

Source:
Returns:

The scale.

Type
Number

legendUrl() → {LegendUrl}

Returns the legendUrl for this legend. Can be called directly after instantiation.

Source:
Returns:

The Legend URL object for the legend, with its url being a base64-encoded PNG.

Type
LegendUrl