English
Class: D3PColorLegend
Defined in: core/color.ts:145
A gradient bar with a scale, for a D3PColorScale. Drawn in the chart's SVG (no HTML), so it is part of exports.
Extends
D3PAttachable<ColorLegendData>
Constructors
Constructor
ts
new D3PColorLegend(opts): D3PColorLegend;Defined in: core/color.ts:163
Parameters
opts
Returns
D3PColorLegend
Overrides
Methods
addToChart()
ts
addToChart(chart): void;Defined in: core/object.ts:77
Attaches the object to a chart; nothing happens if it already is attached to it.
Parameters
chart
Returns
void
Inherited from
attached()
ts
protected attached(
chart,
_data,
subs
): void;Defined in: core/color.ts:182
Subscribe / create DOM. Subscriptions added to subs are released on detach.
Parameters
chart
_data
ColorLegendData
subs
Returns
void
Overrides
createData()
ts
protected createData(chart): ColorLegendData;Defined in: core/color.ts:175
Build the per-chart record. Must not rely on other objects of the chart.
Parameters
chart
Returns
ColorLegendData
Overrides
destroy()
ts
destroy(): void;Defined in: core/object.ts:51
Detaches the object from all its charts, announces destroyed and releases its subscriptions. The object cannot be used afterwards.
Returns
void
Inherited from
detached()
ts
protected detached(_chart, data): void;Defined in: core/color.ts:188
DOM / registry cleanup (subscriptions are released afterwards).
Parameters
_chart
data
ColorLegendData
Returns
void
Overrides
fire()
ts
protected fire<P>(event, ...args): void;Defined in: core/object.ts:41
Emits one of its own events on the bus.
Type Parameters
P
P
Parameters
event
D3PEvent<P>
args
...P extends void ? [] : [payload: P]
Returns
void
Inherited from
getCharts()
ts
getCharts(): D3PChart[];Defined in: core/object.ts:105
The charts the object is attached to.
Returns
D3PChart[]
Inherited from
hasChart()
ts
hasChart(chart): boolean;Defined in: core/object.ts:110
Whether the object is attached to this chart.
Parameters
chart
Returns
boolean
Inherited from
onDestroy()
ts
protected onDestroy(): void;Defined in: core/color.ts:247
Hook run first on destroy (detach from partners, release DOM...).
Returns
void
Overrides
removeFromChart()
ts
removeFromChart(chart): void;Defined in: core/object.ts:95
Detaches the object from a chart; nothing happens if it is not attached to it.
Parameters
chart
Returns
void
Inherited from
render()
ts
render(chart): void;Defined in: core/color.ts:194
Draws the gradient bar, its ticks and its title.
Parameters
chart
Returns
void
Overrides
tagDirty()
ts
tagDirty(chart?): void;Defined in: core/object.ts:119
Schedule a redraw on one chart (or all attached charts).
Parameters
chart?
Returns
void
Inherited from
Properties
bus
ts
readonly bus: D3PBus;Defined in: core/object.ts:27
The bus the object uses for its events.
Inherited from
chartData
ts
protected readonly chartData: Map<D3PChart, ColorLegendData>;Defined in: core/object.ts:66
What the object keeps for each chart it is attached to.
Inherited from
e
ts
readonly e: D3PEventTable<M & object>;Defined in: core/object.ts:29
The events of the object, by name: destroyed for all, and its own (axis.e.scaleChanged).
Inherited from
inside
ts
inside: boolean;Defined in: core/color.ts:155
Whether the legend floats over a corner of the plot instead of taking room in the margin.
isDestroying
ts
isDestroying: boolean = false;Defined in: core/object.ts:31
Set when destroy starts: the object is not drawn after that.
Inherited from
length
ts
length: number;Defined in: core/color.ts:151
Length of the gradient bar, in pixels.
position
ts
position: NonNullable<"top" | "right" | "bottom" | "left" | undefined>;Defined in: core/color.ts:149
The side of the chart the legend goes on.
scale
ts
readonly scale: D3PColorScale;Defined in: core/color.ts:147
The scale the legend shows.
subs
ts
protected readonly subs: D3PSubscriptions;Defined in: core/object.ts:33
The subscriptions of the object, released when it is destroyed.
Inherited from
thickness
ts
thickness: number;Defined in: core/color.ts:153
Thickness of the gradient bar, in pixels.
tickCount
ts
tickCount: number;Defined in: core/color.ts:157
The number of ticks along the bar.
tickFormat
ts
tickFormat: ((v) => string) | undefined;Defined in: core/color.ts:159
Writes the values of the ticks.
title
ts
title: string | undefined;Defined in: core/color.ts:161
The title above the bar.