Skip to content
EliteChart

PercentScale

Documentation


Documentation / @elitechart/core / PercentScale

Defined in: math/scales.ts:172

Percent scale, expressed as % change from an anchor value.

scale(anchor) === range center scale(anchor * (1 + p/100)) = range center + p * unitPx

Internally just a linear scale over percentage values; exposed as a named type for clarity at call sites.

Example

code
import { PercentScale } from '@elitechart/core';
const pct = new PercentScale(100, { min: -10, max: 10 }, { start: 600, end: 0 });
pct.scale(110);  // top of the +10% band
pct.scale(90);   // bottom of the -10% band

Implements

Constructors

Constructor

code
new PercentScale(
   anchor, 
   percentDomain, 
   range): PercentScale;

Defined in: math/scales.ts:178

Parameters

anchor

number

percentDomain

Domain

range

Range

Returns

PercentScale

Properties

anchor

code
readonly anchor: number;

Defined in: math/scales.ts:175


domain

code
readonly domain: Domain;

Defined in: math/scales.ts:173

Implementation of

Scale.domain


range

code
readonly range: Range;

Defined in: math/scales.ts:174

Implementation of

Scale.range

Methods

invert()

code
invert(px): number;

Defined in: math/scales.ts:193

Map a pixel back to the domain.

Parameters

px

number

Returns

number

Implementation of

Scale.invert


scale()

code
scale(value): number;

Defined in: math/scales.ts:188

Map a domain value to a pixel position.

Parameters

value

number

Returns

number

Implementation of

Scale.scale