Skip to content

Class: D3PColorScale ​

Defined in: core/color.ts:29

A sequential color scale for heatmaps. Its domain is a D3PAxisDomain, so it can be fitted to data by an auto domain (linkSeries(series, { value: scale.domain })) and shared between charts.

Extends ​

Accessors ​

bins ​

Get Signature ​

ts
get bins(): number | undefined;

Defined in: core/color.ts:55

The number of colors the scale is cut into, or undefined for a continuous gradient.

Returns ​

number | undefined

Set Signature ​

ts
set bins(n): void;

Defined in: core/color.ts:59

Sets the number of colors; the heatmaps that use the scale are drawn again.

Parameters ​
n ​

number | undefined

Returns ​

void


interpolator ​

Get Signature ​

ts
get interpolator(): (t) => string;

Defined in: core/color.ts:46

The function that turns a position from 0 to 1 into a color (d3.interpolateYlOrRd by default).

Returns ​

(t) => string

Set Signature ​

ts
set interpolator(f): void;

Defined in: core/color.ts:50

Sets the interpolator; the heatmaps that use the scale are drawn again.

Parameters ​
f ​

(t) => string

Returns ​

void


reverse ​

Get Signature ​

ts
get reverse(): boolean;

Defined in: core/color.ts:64

Whether the scale is reversed: the largest values get the first color.

Returns ​

boolean

Set Signature ​

ts
set reverse(v): void;

Defined in: core/color.ts:68

Reverses the scale or not; the heatmaps that use it are drawn again.

Parameters ​
v ​

boolean

Returns ​

void

Constructors ​

Constructor ​

ts
new D3PColorScale(opts?): D3PColorScale;

Defined in: core/color.ts:36

Parameters ​

opts? ​

D3PColorScaleOptions = {}

Returns ​

D3PColorScale

Overrides ​

D3PObject.constructor

Methods ​

color() ​

ts
color(value): string;

Defined in: core/color.ts:89

The color of a value: the interpolator at its place in the domain, clamped to the ends.

Parameters ​

value ​

number

Returns ​

string


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 ​

D3PObject.destroy


extent() ​

ts
extent(): [number, number];

Defined in: core/color.ts:74

[min, max] as numbers.

Returns ​

[number, number]


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 ​

D3PObject.fire


onDestroy() ​

ts
protected onDestroy(): void;

Defined in: core/color.ts:99

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

Returns ​

void

Overrides ​

D3PObject.onDestroy


position() ​

ts
position(value): number;

Defined in: core/color.ts:80

Position of value in the scale, 0 to 1 (clamped; stepped when the scale has bins).

Parameters ​

value ​

number

Returns ​

number


stops() ​

ts
stops(n?): object[];

Defined in: core/color.ts:94

Evenly spaced stops from the low end to the high end, for a gradient.

Parameters ​

n? ​

number = 24

Returns ​

object[]

Properties ​

bus ​

ts
readonly bus: D3PBus;

Defined in: core/object.ts:27

The bus the object uses for its events.

Inherited from ​

D3PObject.bus


domain ​

ts
readonly domain: D3PAxisDomain;

Defined in: core/color.ts:31

The domain of the values. Fit it to the data with an auto domain, or share it between charts.


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 ​

D3PObject.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 ​

D3PObject.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 ​

D3PObject.subs