Skip to content

Documentation / @ripl/charts / ColorLegend

Class: ColorLegend ​

Defined in: charts/src/components/color-legend.ts:88

A continuous-color legend: a gradient bar (approximated by solid segments so it works identically on Canvas and SVG) annotated with formatted value labels drawn from a ColorScale. Renders into a reserved region like the other chart components; formatting is supplied explicitly, keeping the scale and the formatter decoupled.

Extends ​

  • ChartComponent

Constructors ​

Constructor ​

new ColorLegend(__namedParameters): ColorLegend

Defined in: charts/src/components/color-legend.ts:94

Parameters ​

ParameterType
__namedParametersColorLegendComponentOptions

Returns ​

ColorLegend

Overrides ​

ChartComponent.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
parent?publicEventBus<EventMap>The parent event bus that emitted events bubble up to, if any.ChartComponent.parentcore/src/core/event-bus.ts:107
rendererprotectedRenderer-ChartComponent.renderercharts/src/components/_base/index.ts:23
sceneprotectedScene-ChartComponent.scenecharts/src/components/_base/index.ts:22
defaultKeyreadonlytypeof defaultKeyThe key under which resources are retained when no explicit key is provided.ChartComponent.defaultKeycore/src/core/disposer.ts:11

Accessors ​

$events ​

Get Signature ​

get $events(): keyof TEventMap[]

Defined in: core/src/core/event-bus.ts:114

The event types this bus can emit. The base returns an empty list; subclasses override it to declare their emittable events (type-checked against their EventMap), so tooling such as the devtools can enumerate them, including events added by custom subclasses.

Returns ​

keyof TEventMap[]

Inherited from ​

ChartComponent.$events


context ​

Get Signature ​

get protected context(): Context<Element, Record<string, unknown>>

Defined in: charts/src/components/_base/index.ts:25

Returns ​

Context<Element, Record<string, unknown>>

Inherited from ​

ChartComponent.context

Methods ​

destroy() ​

destroy(): void

Defined in: charts/src/components/color-legend.ts:216

Removes the legend's elements from the scene.

Returns ​

void

Overrides ​

ChartComponent.destroy


dispose() ​

protected dispose(key?): void

Defined in: core/src/core/disposer.ts:25

Disposes all resources under the given key, or all resources if no key is provided.

Parameters ​

ParameterType
key?PropertyKey

Returns ​

void

Inherited from ​

ChartComponent.dispose


emit() ​

Call Signature ​

emit<TEvent>(event): TEvent

Defined in: core/src/core/event-bus.ts:185

Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.

Type Parameters ​
Type ParameterDefault type
TEvent extends Event<undefined>Event<undefined>
Parameters ​
ParameterType
eventTEvent
Returns ​

TEvent

Inherited from ​

ChartComponent.emit

Call Signature ​

emit<TEvent>(type, data): Event<EventMap[TEvent]>

Defined in: core/src/core/event-bus.ts:186

Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.

Type Parameters ​
Type Parameter
TEvent extends keyof EventMap
Parameters ​
ParameterType
typeTEvent
dataEventMap[TEvent]
Returns ​

Event<EventMap[TEvent]>

Inherited from ​

ChartComponent.emit


has() ​

has(type): boolean

Defined in: core/src/core/event-bus.ts:123

Returns whether there are any listeners registered for the given event type. Wildcard subscriptions (EVENT_WILDCARD) are not listeners for any concrete type, so a bus observed only through the wildcard still reports false here.

Parameters ​

ParameterType
typekeyof EventMap

Returns ​

boolean

Inherited from ​

ChartComponent.has


measure() ​

measure(): number

Defined in: charts/src/components/color-legend.ts:149

The thickness of the band this legend needs (padding inset plus bar plus labels).

Returns ​

number


off() ​

off<TEvent>(type, handler): void

Defined in: core/src/core/event-bus.ts:144

Removes a previously registered handler for the given event type.

Type Parameters ​

Type Parameter
TEvent extends keyof EventMap

Parameters ​

ParameterType
typeTEvent
handlerEventHandler<EventMap[TEvent]>

Returns ​

void

Inherited from ​

ChartComponent.off


on() ​

on<TEvent>(type, handler, options?): Disposable

Defined in: core/src/core/event-bus.ts:131

Subscribes a handler to the given event type and returns a disposable for cleanup. Pass EVENT_WILDCARD to receive every event emitted on the bus regardless of type.

Type Parameters ​

Type Parameter
TEvent extends keyof EventMap

Parameters ​

ParameterType
typeTEvent
handlerEventHandler<EventMap[TEvent]>
options?EventSubscriptionOptions

Returns ​

Disposable

Inherited from ​

ChartComponent.on


once() ​

once<TEvent>(type, handler, options?): Disposable

Defined in: core/src/core/event-bus.ts:159

Subscribes a handler that is automatically removed after it fires once.

Type Parameters ​

Type Parameter
TEvent extends keyof EventMap

Parameters ​

ParameterType
typeTEvent
handlerEventHandler<EventMap[TEvent]>
options?EventSubscriptionOptions

Returns ​

Disposable

Inherited from ​

ChartComponent.once


render() ​

render(region): void

Defined in: charts/src/components/color-legend.ts:154

Draws (or redraws) the legend within the reserved region.

Parameters ​

ParameterType
regionChartArea

Returns ​

void


retain() ​

protected retain(value, key?): void

Defined in: core/src/core/disposer.ts:14

Registers a disposable resource under an optional key for later cleanup.

Parameters ​

ParameterTypeDefault value
valueDisposableundefined
keyPropertyKeyDisposer.defaultKey

Returns ​

void

Inherited from ​

ChartComponent.retain


setOptions() ​

setOptions(options): void

Defined in: charts/src/components/color-legend.ts:141

Updates the legend's visual options.

Parameters ​

ParameterType
optionsColorLegendOptions

Returns ​

void


setScale() ​

setScale(scale): void

Defined in: charts/src/components/color-legend.ts:136

Updates the color scale the legend renders.

Parameters ​

ParameterType
scaleColorScale

Returns ​

void