Documentation / @finchart/core / index / LogScale
Class: LogScale
Defined in: packages/core/src/scale/log-scale.ts:141
Pairs well with priceFormat() on the axis: the log ladder's local step (tickGeometry) is what lets a step-aware formatter show 0.00003 near the floor of a wide domain instead of 0.00.
Implements
Constructors
Constructor
new LogScale(
domainMin?,domainMax?,rangeMin?,rangeMax?):LogScale
Defined in: packages/core/src/scale/log-scale.ts:146
Parameters
domainMin?
number
domainMax?
number
rangeMin?
number
rangeMax?
number
Returns
LogScale
Properties
kind
readonlykind:string="log"
Defined in: packages/core/src/scale/log-scale.ts:142
Stable scale kind. Custom scales declare their own kind for declarative pane updates.
Implementation of
Methods
expand()
expand(
range,ratio,hints?): [number,number]
Defined in: packages/core/src/scale/log-scale.ts:448
Pads linearly in log space.
On screen it looks the same as a linear axis — "ratio's worth of room above and below" — but in values it becomes a multiplication: [min / f, max × f], f = (max/min)^ratio.
The result can't cross 0 — as long as the input is already positive. But expand receives the raw data, so if a non-positive value like close: 0 is mixed in, Math.pow(max/0, ratio) = Infinity, and a negative value produces NaN. If that value reached setDomain unchanged, the message would look like a finiteness problem and hide the real cause (a non-positive value mixed in).
So only the positive part of the interval is kept — mixing in a value at or below 0 doesn't throw here. Those values have no place on a log axis, so they simply fall off below the axis (the same treatment an off-screen value gets on a linear axis). Only when there's no positive value at all is it truly undrawable, and setDomain below states that under its own name, with "LogScale domain must be positive".
Unfilled orders and halted candles' close: 0, and negative settlement prices, are where these values come from.
Parameters
range
readonly [number, number]
ratio
number
hints?
Returns
[number, number]
Implementation of
getDomain()
getDomain(): [
number,number]
Defined in: packages/core/src/scale/log-scale.ts:178
The data domain [min, max].
Returns
[number, number]
Implementation of
getRange()
getRange(): [
number,number]
Defined in: packages/core/src/scale/log-scale.ts:182
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]
Implementation of
invert()
invert(
screenValue):number
Defined in: packages/core/src/scale/log-scale.ts:227
Screen coordinate → data value.
Parameters
screenValue
number
Returns
number
Implementation of
scale()
scale(
value):number
Defined in: packages/core/src/scale/log-scale.ts:204
Value → pixel.
A value at or below 0 doesn't throw — it's sent off below the axis. This function is on the draw path — a series calls it per point, and a single close: 0 candle mixed in would otherwise kill the whole frame. On a log axis, 0 is a value infinitely far below, not a contract violation.
It gets the same treatment an off-screen value gets on a linear axis — a pixel comes out, it's just outside the area so nothing draws there. The actual contract violation (a domain with no positive value at all) is still rejected by setDomain, under its own name.
Returning a finite value instead of -Infinity matters — a non-finite coordinate turns fillRect into a no-op, wiping out the whole body.
Parameters
value
number
Returns
number
Implementation of
setDomain()
setDomain(
min,max):void
Defined in: packages/core/src/scale/log-scale.ts:165
Check finiteness first — checking only min <= 0 || max <= 0 would let max = Infinity through, since Infinity > 0, and that can reach an infinite tick loop.
Parameters
min
number
max
number
Returns
void
Implementation of
setRange()
setRange(
start,end):void
Defined in: packages/core/src/scale/log-scale.ts:174
Parameters
start
number
end
number
Returns
void
Implementation of
tickGeometry()
tickGeometry(
minTickSpacing):TickGeometry
Defined in: packages/core/src/scale/log-scale.ts:304
Tick geometry on this scale's own arithmetic — the ladder of 1·2·5 mantissas over decades, or a linear run when the window is narrow enough that the ladder would be sparser. One predicate decides: whichever candidate keeps more ticks wins (tie goes to the ladder — its values are the rounder ones, and its membership doesn't depend on where the domain's edges sit, so panning can't reshuffle the interior). There is no threshold constant to snap at.
Parameters
minTickSpacing
number