Documentation / @ripl/charts / ColorLegend
Class: ColorLegend
Defined in: charts/src/components/color-legend.ts:80
A continuous-colour 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:86
Parameters
| Parameter | Type |
|---|---|
__namedParameters | ColorLegendComponentOptions |
Returns
ColorLegend
Overrides
ChartComponent.constructor
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
parent? | public | EventBus<EventMap> | The parent event bus that emitted events bubble up to, if any. | ChartComponent.parent | core/src/core/event-bus.ts:89 |
renderer | protected | Renderer | - | ChartComponent.renderer | charts/src/components/_base/index.ts:23 |
scene | protected | Scene | - | ChartComponent.scene | charts/src/components/_base/index.ts:22 |
defaultKey | readonly | typeof defaultKey | The key under which resources are retained when no explicit key is provided. | ChartComponent.defaultKey | core/src/core/disposer.ts:11 |
Accessors
context
Get Signature
get
protectedcontext():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:205
Removes the legend's elements from the scene.
Returns
void
Overrides
ChartComponent.destroy
dispose()
protecteddispose(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
| Parameter | Type |
|---|---|
key? | PropertyKey |
Returns
void
Inherited from
ChartComponent.dispose
emit()
Call Signature
emit<
TEvent>(event):TEvent
Defined in: core/src/core/event-bus.ts:137
Emits an event, invoking all matching handlers and bubbling to the parent if applicable.
Type Parameters
| Type Parameter | Default type |
|---|---|
TEvent extends Event<undefined> | Event<undefined> |
Parameters
| Parameter | Type |
|---|---|
event | TEvent |
Returns
TEvent
Inherited from
ChartComponent.emit
Call Signature
Defined in: core/src/core/event-bus.ts:138
Emits an event, invoking all matching handlers and bubbling to the parent if applicable.
Type Parameters
| Type Parameter |
|---|
TEvent extends keyof EventMap |
Parameters
| Parameter | Type |
|---|---|
type | TEvent |
data | EventMap[TEvent] |
Returns
Inherited from
ChartComponent.emit
has()
has(
type):boolean
Defined in: core/src/core/event-bus.ts:94
Returns whether there are any listeners registered for the given event type.
Parameters
| Parameter | Type |
|---|---|
type | keyof EventMap |
Returns
boolean
Inherited from
ChartComponent.has
measure()
measure():
number
Defined in: charts/src/components/color-legend.ts:141
The thickness of the band this legend needs (bar plus labels).
Returns
number
off()
off<
TEvent>(type,handler):void
Defined in: core/src/core/event-bus.ts:112
Removes a previously registered handler for the given event type.
Type Parameters
| Type Parameter |
|---|
TEvent extends keyof EventMap |
Parameters
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<EventMap[TEvent]> |
Returns
void
Inherited from
ChartComponent.off
on()
on<
TEvent>(type,handler,options?):Disposable
Defined in: core/src/core/event-bus.ts:99
Subscribes a handler to the given event type and returns a disposable for cleanup.
Type Parameters
| Type Parameter |
|---|
TEvent extends keyof EventMap |
Parameters
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<EventMap[TEvent]> |
options? | EventSubscriptionOptions |
Returns
Inherited from
ChartComponent.on
once()
once<
TEvent>(type,handler,options?):Disposable
Defined in: core/src/core/event-bus.ts:127
Subscribes a handler that is automatically removed after it fires once.
Type Parameters
| Type Parameter |
|---|
TEvent extends keyof EventMap |
Parameters
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<EventMap[TEvent]> |
options? | EventSubscriptionOptions |
Returns
Inherited from
ChartComponent.once
render()
render(
region):void
Defined in: charts/src/components/color-legend.ts:146
Draws (or redraws) the legend within the reserved region.
Parameters
| Parameter | Type |
|---|---|
region | ChartArea |
Returns
void
retain()
protectedretain(value,key?):void
Defined in: core/src/core/disposer.ts:14
Registers a disposable resource under an optional key for later cleanup.
Parameters
| Parameter | Type | Default value |
|---|---|---|
value | Disposable | undefined |
key | PropertyKey | Disposer.defaultKey |
Returns
void
Inherited from
ChartComponent.retain
setOptions()
setOptions(
options):void
Defined in: charts/src/components/color-legend.ts:133
Updates the legend's visual options.
Parameters
| Parameter | Type |
|---|---|
options | ColorLegendOptions |
Returns
void
setScale()
setScale(
scale):void
Defined in: charts/src/components/color-legend.ts:128
Updates the colour scale the legend renders.
Parameters
| Parameter | Type |
|---|---|
scale | ColorScale |
Returns
void