When true, autoScale() is skipped — priceMin/priceMax stay
frozen at the user-chosen range. Set by scalePriceRangeBy() when
the user drags the price axis. Cleared by resetPriceScale().
Number of empty-candle slots kept between the last candle and the right edge of the chart area. Leaves breathing room for the forming live candle.
Active price-axis transform. 'linear' keeps the original render
path byte-for-byte; 'log'/'percentage'/'indexedTo100' route
through priceToTransformed. Set via setScaleMode.
Total width per candle (body + gap)
Upper bound of the secondary (left) price scale.
Lower bound of the secondary (left) price scale.
Transform mode of the secondary (left) price scale.
Auto-scale price/volume from the visible buffer data.
accel (optional) is a coarse range index used only when the visible
window is huge (sub-pixel fitAll) and the mode isn't log — it turns a
per-frame O(window) scan into ≈ O(window / block). Omit it and the
original linear scan runs, preserving all four guards (manual-mode
volume rescan, empty window, NaN-skip, flat-range).
maxLength (optional) caps the upper index the scan/clamp may reach.
Defaults to buffer.length, so omitting it is bit-for-bit identical to
the pre-replay behavior. Replay mode (C1) passes the effective (capped)
length so autoscale never peeks at not-yet-revealed candles even if the
viewport's visible window nominally extends past the cap.
Optionalaccel: RangeSourceOptionalmaxLength: numberAuto-scale from a pre-built (possibly transformed) view rather than the
raw buffer — used by series with a transformView (Heikin-Ashi) or a
custom priceRange. Scans the view linearly (no range pyramid). Honors
the same manual / empty / NaN / log / flat-range guards as autoScale.
OptionalpriceRange: (v: CandleView, i: number) => { max: number; min: number }OptionalmaxLength: numberFit all candles from the buffer into the visible chart area by adjusting candleWidth. Useful for "show me everything" action. Scrolls to the start.
Reset candleWidth to the default value and scroll to the live edge. Useful for "back to normal" action after deep zoom. Also resets the manual price scale so the next auto-scale runs from scratch.
Format a price value as a Y-axis label in the active scale mode.
Returns a pre-formatted string for percentage/indexedTo100 modes
(e.g. "+10.00%") so all axis pills — grid ticks, current-price pill,
and crosshair pill — show consistent transformed units. Returns null
for linear and log so the caller applies its own price formatter.
Scroll to the live edge without changing candleWidth. Re-enables autoFollow.
Price-axis grid ticks for the current scale mode. Shared by the
grid renderer and the price-axis renderer so they never diverge.
For linear/log, label is null (caller formats the price); for
percentage/indexed, label is the pre-formatted axis string.
Convert buffer index to X pixel coordinate
True only when the viewport is resting exactly at the live anchor position (last candle sits at chartRight - rightPaddingCandles).
The tolerance is < 0.5 candle so that fractional pan deltas from panPixels() still snap cleanly. Panning even one full candle past the anchor into the empty future zone counts as "user exploring the future" and returns false — which prevents live updates from jerking the view back to the anchor on every tick.
Check if viewport is at the start of data
Pan by delta index units
Pan by a pixel delta (as reported by wheel or touch events).
Positive dx means the content moves right (show older candles);
negative dx means the content moves left (show newer candles).
Convert price to Y pixel coordinate.
side selects the price scale: 'right' (default) is the primary
scale and runs the original arithmetic untouched — every existing
caller omits the argument, so the default path is bit-for-bit
unchanged. 'left' projects through the independent secondary scale
(see setLeftRange).
Exit manual price-scale mode; the next autoScale() call will
recompute priceMin/priceMax from the visible candles again.
Scale the price range by factor around an anchor Y coordinate
(the pixel under the user's cursor at drag-start). factor > 1
expands the visible range (zoom out vertically — shorter candles),
factor < 1 contracts it (zoom in vertically — taller candles).
Switches the viewport to manual price-scale mode — subsequent
autoScale() calls are skipped until resetPriceScale() is
called.
Scroll to the end of data, leaving rightPaddingCandles of empty space.
Install a non-uniform index→0..1 horizontal mapping (value-based scales), or pass null to restore uniform index spacing. The default is null, so the standard time chart's geometry is untouched.
Set the secondary (left) price scale's raw extrema, applying the same
flat-range protection + linear padding as the right axis's
_applyPriceRange. Called by the engine after collecting the
min/max of every indicator bound to 'left'. No-op-safe: a degenerate
or non-finite pair leaves the previous range intact.
Switch the price-axis transform. Clears any manual (frozen) scale so
the next autoScale re-derives a sane range for the new mode.
Install a time → (fractional) buffer-index resolver, or pass null to clear it. The engine sets this every frame from the main buffer so overlays that own their own time-keyed series (timeToX) align to the price axis. The default is null, so a chart with no buffer (or no overlay consumer) pays nothing and timeToX returns NaN.
Project a timestamp onto the chart's X axis, aligned with the main price series. Resolves the timestamp to a (possibly fractional) buffer index via the engine-installed resolver, then through the same indexToX the candles use — so a value-based horizontal scale, zoom, and pan all carry over for free. Returns NaN when no resolver is installed (no buffer) or the resolver itself can't place the time, letting a caller skip that point instead of drawing at a bogus X.
Convert volume to Y pixel coordinate
Convert X pixel to nearest buffer index
Convert Y pixel to price. side selects the scale; 'right' (default)
is the primary scale and is unchanged for every existing caller.
Zoom around a center X coordinate
When true, new data appended to the buffer auto-scrolls the viewport to keep the newest candle in view. Set to false automatically when the user pans away from the right edge, and back to true when they pan back or explicitly call
goToLive().