Skip to main content

Class: ColorScale

Defined in: src/mobjects/geo/colorScale.ts:29

Maps numeric values to #rrggbb colors across a domain.

Constructors​

Constructor​

new ColorScale(options): ColorScale

Defined in: src/mobjects/geo/colorScale.ts:33

Parameters​

options​

ColorScaleOptions = {}

Returns​

ColorScale

Methods​

colorFor()​

colorFor(value): string

Defined in: src/mobjects/geo/colorScale.ts:73

Map a value to a color. Values outside the domain clamp to the endpoints. A zero-width domain maps everything to the first palette color.

Parameters​

value​

number

The value to map.

Returns​

string

A #rrggbb color string.


getDomain()​

getDomain(): [number, number]

Defined in: src/mobjects/geo/colorScale.ts:62

Get the current domain [min, max].

Returns​

[number, number]


setDomainFromValues()​

setDomainFromValues(values): this

Defined in: src/mobjects/geo/colorScale.ts:47

Set the domain from a list of values (its min and max). Non-finite values are ignored. Leaves the domain unchanged when no finite value is present.

Parameters​

values​

number[]

The data values.

Returns​

this

this for chaining.