Documentation / @finchart/core / index / Scale
Interface: Scale
Defined in: packages/core/src/scale/types.ts:6
The one-way mapping from data domain to screen coordinates. It's mutable because the domain keeps changing during pan/zoom. Bad input is signaled by throwing, not by returning a Result.
Properties
kind
readonlykind:string
Defined in: packages/core/src/scale/types.ts:8
Stable scale kind. Custom scales declare their own kind for declarative pane updates.
Methods
expand()?
optionalexpand(range,ratio,hints?): [number,number]
Defined in: packages/core/src/scale/types.ts:44
Pads the data interval with its own arithmetic. Omit it and linear addition is used ([min - span·ratio, max + span·ratio]) — a scale whose default arithmetic is good enough needs nothing here, and only a scale with different geometry supplies its own.
The log axis is the real consumer that forced this hook to exist — additive padding subtracts more the smaller min is, so on data with a wide interval the lower bound crosses 0 and LogScale.setDomain rejects it.
ratio is a fraction of the interval's width — what "width" means is up to the scale (linear: width in value space, log: width in log space).
Parameters
range
readonly [number, number]
ratio
number
hints?
Returns
[number, number]
getDomain()
getDomain(): [
number,number]
Defined in: packages/core/src/scale/types.ts:10
The data domain [min, max].
Returns
[number, number]
getRange()
getRange(): [
number,number]
Defined in: packages/core/src/scale/types.ts:19
The screen range [start, end] (px).
A reversed range (start > end) is allowed. Screen y increases downward, so the y axis is set to [bottom, top] to put larger values on top — the scale has to hold this inversion so the chart and the axis agree on the same coordinates.
Returns
[number, number]
invert()
invert(
screenValue):number
Defined in: packages/core/src/scale/types.ts:27
Screen coordinate → data value.
Parameters
screenValue
number
Returns
number
scale()
scale(
value):number
Defined in: packages/core/src/scale/types.ts:25
Data value → screen coordinate.
Parameters
value
number
Returns
number
setDomain()
setDomain(
min,max):void
Defined in: packages/core/src/scale/types.ts:21
Parameters
min
number
max
number
Returns
void
setRange()
setRange(
min,max):void
Defined in: packages/core/src/scale/types.ts:22
Parameters
min
number
max
number
Returns
void
tickGeometry()?
optionaltickGeometry(minTickSpacing):TickGeometry
Defined in: packages/core/src/scale/types.ts:62
Tick geometry in this scale's own arithmetic — where the log axis's decade ladder goes. Omit it and the linear default arithmetic is used; same shape as expand: only a scale with different geometry supplies its own.
Placement only, never labels — the axis combines these values with whatever format is in force, so a user's formatter keeps working when the scale changes. minTickSpacing arrives already resolved by the caller; the pixel span comes from this scale's own getRange(), so there is no second source for either number.
Parameters
minTickSpacing
number