Skip to content

Class: D3PLegendPanel ​

Defined in: core/legend-panel.ts:50

A standard legend: one line per entry of the renderers (a name, a color, a click that shows or hides what it stands for). It reads the entries from a D3PLegendManager and draws them in the element of a D3PSlot, which is what a legend of your own does too. Opt in by attaching it to the chart; instead, D3PLegendBundle leaves the content to you.

Extends ​

Accessors ​

props ​

Get Signature ​

ts
get props(): D3PProps<D3PLegendPanelProps>;

Defined in: core/legend-panel.ts:68

The props of the panel: its alignment and its style.

Returns ​

D3PProps<D3PLegendPanelProps>

Set Signature ​

ts
set props(v): void;

Defined in: core/legend-panel.ts:72

Merges props into those of the panel.

Parameters ​
v ​
align? ​

"start" | "end" | "center"

Along the side, over the plot: the start, the middle or the end of it.

style? ​

{ color?: string; fontSize?: number; gap?: number; swatch?: number; }

Color and size of the text, the gap between entries and the size of the swatch.

style.color? ​

string

style.fontSize? ​

number

style.gap? ​

number

style.swatch? ​

number

Returns ​

void

Constructors ​

Constructor ​

ts
new D3PLegendPanel(opts?): D3PLegendPanel;

Defined in: core/legend-panel.ts:59

Parameters ​

opts? ​

D3PLegendPanelOptions = {}

Returns ​

D3PLegendPanel

Overrides ​

D3PAttachable.constructor

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 ​

D3PChart

Returns ​

void

Inherited from ​

D3PAttachable.addToChart


attached() ​

ts
protected attached(
   chart, 
   data, 
   subs
): void;

Defined in: core/legend-panel.ts:88

Subscribe / create DOM. Subscriptions added to subs are released on detach.

Parameters ​

chart ​

D3PChart

data ​
legend? ​

D3PLegend

manager ​

D3PLegendManager

slot ​

D3PSlot

subs ​

D3PSubscriptions

Returns ​

void

Overrides ​

D3PAttachable.attached


createData() ​

ts
protected createData(): object;

Defined in: core/legend-panel.ts:80

Build the per-chart record. Must not rely on other objects of the chart.

Returns ​

object

manager ​
ts
manager: D3PLegendManager;
slot ​
ts
slot: D3PSlot;

Overrides ​

D3PAttachable.createData


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 ​

D3PAttachable.destroy


detached() ​

ts
protected detached(_chart, data): void;

Defined in: core/legend-panel.ts:103

DOM / registry cleanup (subscriptions are released afterwards).

Parameters ​

_chart ​

D3PChart

data ​
manager ​

D3PLegendManager

slot ​

D3PSlot

Returns ​

void

Overrides ​

D3PAttachable.detached


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 ​

D3PAttachable.fire


getCharts() ​

ts
getCharts(): D3PChart[];

Defined in: core/object.ts:105

The charts the object is attached to.

Returns ​

D3PChart[]

Inherited from ​

D3PAttachable.getCharts


hasChart() ​

ts
hasChart(chart): boolean;

Defined in: core/object.ts:110

Whether the object is attached to this chart.

Parameters ​

chart ​

D3PChart

Returns ​

boolean

Inherited from ​

D3PAttachable.hasChart


onDestroy() ​

ts
protected onDestroy(): void;

Defined in: core/object.ts:114

Hook run first on destroy (detach from partners, release DOM...).

Returns ​

void

Inherited from ​

D3PAttachable.onDestroy


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 ​

D3PChart

Returns ​

void

Inherited from ​

D3PAttachable.removeFromChart


render() ​

ts
render(_chart): void | Promise<void>;

Defined in: core/object.ts:129

Draws the object on a chart. The render manager calls it, once per frame, for the objects that asked for it.

Parameters ​

_chart ​

D3PChart

Returns ​

void | Promise<void>

Inherited from ​

D3PAttachable.render


tagDirty() ​

ts
tagDirty(chart?): void;

Defined in: core/object.ts:119

Schedule a redraw on one chart (or all attached charts).

Parameters ​

chart? ​

D3PChart

Returns ​

void

Inherited from ​

D3PAttachable.tagDirty

Properties ​

bus ​

ts
readonly bus: D3PBus;

Defined in: core/object.ts:27

The bus the object uses for its events.

Inherited from ​

D3PAttachable.bus


chartData ​

ts
protected readonly chartData: Map<D3PChart, {
  legend?: D3PLegend;
  manager: D3PLegendManager;
  slot: D3PSlot;
}>;

Defined in: core/object.ts:66

What the object keeps for each chart it is attached to.

Inherited from ​

D3PAttachable.chartData


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 ​

D3PAttachable.e


isDestroying ​

ts
isDestroying: boolean = false;

Defined in: core/object.ts:31

Set when destroy starts: the object is not drawn after that.

Inherited from ​

D3PAttachable.isDestroying


subs ​

ts
protected readonly subs: D3PSubscriptions;

Defined in: core/object.ts:33

The subscriptions of the object, released when it is destroyed.

Inherited from ​

D3PAttachable.subs