JavaScript & React libraryAPI

Class: SizeLegend

The SizeLegend class is responsible for rendering a size legend UI component. It provides methods to set the configuration, show/hide the legend, and handle user interactions.

The legend displays a visual representation of the size scale, with minimum and maximum size indicators. It also supports optional labels and event handlers for click and hover interactions.

The class takes a container node and an optional configuration object in the constructor. The configuration can be updated at any time using the setConfig method.

Extends

Constructors

Constructor

new SizeLegend(containerNode, config?): SizeLegend

Constructs a new SizeLegend instance with the provided container node and optional configuration.

Parameters

ParameterTypeDescription
containerNodeHTMLElementThe HTML element that will contain the size legend.
config?SizeLegendConfigInterfaceAn optional configuration object that will be used to initialize the size legend.

Returns

SizeLegend

Overrides

DisplayStateManager.constructor

Accessors

sizeElements

Get Signature

get sizeElements(): null | { min: HTMLElement; max: HTMLElement; }

Gets the min and max size elements used in the size legend.

Returns

null | { min: HTMLElement; max: HTMLElement; }

The min and max size elements, or null if they have not been created yet.


config

Get Signature

get config(): SizeLegendConfigInterface

Gets the current configuration for the size legend.

Returns

SizeLegendConfigInterface

The size legend configuration.


isHidden

Get Signature

get isHidden(): boolean

Gets whether the size legend is currently hidden.

Returns

boolean

true if the size legend is hidden, false otherwise.

Methods

extractConfig()

static extractConfig(config, defaultConfig): DisplayStateConfigInterface

Parameters

ParameterType
configDisplayStateConfigInterface
defaultConfigDisplayStateConfigInterface

Returns

DisplayStateConfigInterface

Inherited from

DisplayStateManager.extractConfig


showState()

showState(text?): void

Shows the DisplayState element with the specified text

Parameters

ParameterTypeDescription
text?stringOptional text to display, defaults to noDataMessage

Returns

void

Inherited from

DisplayStateManager.showState


hideState()

hideState(): void

Hides the DisplayState element

Returns

void

Inherited from

DisplayStateManager.hideState


setDisplayStateConfig()

setDisplayStateConfig(config): void

Updates the DisplayState configuration

Parameters

ParameterType
configDisplayStateConfigInterface

Returns

void

Inherited from

DisplayStateManager.setDisplayStateConfig


hide()

hide(): void

Hides the size legend by removing the ā€˜enabled’ class and adding the ā€˜disabled’ class to the legend element.

Returns

void


show()

show(): void

Shows the size legend by removing the ā€˜disabled’ class and adding the ā€˜enabled’ class to the legend element.

Returns

void


setConfig()

setConfig(config?): void

Sets the configuration for the size legend.

Parameters

ParameterTypeDescription
config?SizeLegendConfigInterfaceAn optional configuration object that will be used to update the size legend.

Returns

void


setLoadingState()

setLoadingState(): void

Sets the text content of the fallback div to ā€˜Data loading…’ to indicate that data is currently being loaded.

Returns

void

Overrides

DisplayStateManager.setLoadingState


destroy()

destroy(): void

Destroys the size legend by removing event listeners and removing the legend and fallback message elements from the container node.

Returns

void

Overrides

DisplayStateManager.destroy