Constructors

Accessors

  • get autoScale(): boolean
  • Whether the range tracks the data (true) or has been set manually (false).

    Returns boolean

  • get baseline(): null | number
  • The baseline last supplied, or null if none (see setBaseline).

    Returns null | number

Methods

  • Recompute the visible range from data extremes + configured margins.

    The range stays in price units in every mode, so the rebasing modes need no separate pass: their transform is affine with a positive scale factor, which maps a margin of 10% of the price span onto a margin of 10% of the percent span. Log is the one that pads in price space and shows it, which is long-standing behaviour and left alone here.

    Parameters

    • low: number
    • high: number
    • progress: number = 1

    Returns boolean

  • Clamp a y to the pane (used by crosshair/order dragging).

    Parameters

    • y: number

    Returns number

  • Format a price for axis/label display. While a rebase is in force the label is the rebased value, "+3.42%" or "103.42", and it outranks a custom price formatter: a currency prefix on a percent change would read as money that is not there. The formatter takes over again the moment the mode does.

    Parameters

    • price: number

    Returns string

  • Pan the visible range vertically by dy media px (dragging the plot up/down). Works in transformed space so it's correct for log scales, and respects inverted. Switches to manual mode so autoscale stops overriding it.

    Parameters

    • dy: number

    Returns void

  • Decimal precision implied by minMove (or the visible range if unset).

    While a rebase is in force the labels are percent/index points, where a price tick size means nothing: precision comes from the transformed span instead, with two decimals as the floor traders expect of a percentage ("+3.42%") and more only when the visible band is tighter than that.

    A scale carrying no tick is not quoting an instrument, so the span is all there is to go on. That alone reads too coarse on a bounded oscillator: an RSI spanning 0 to 100 implies a step of 1 and prints a whole-number ladder, so a reading of 62.24 lands on a rung labelled "62" and a trader comparing it to a 70 level is reading a number that has been rounded past the part they care about. minPrecision is the floor for that case, and it is the same two decimals the percent branch above already settles on for the same reason.

    Returns number

  • Price → y (media px). Higher price → smaller y (top of pane), unless inverted.

    Parameters

    • price: number

    Returns number

  • Forget the measured range and go back to the placeholder.

    Called when a scale loses its last series: the range it holds described something that is no longer on the chart, and whatever arrives next may plot nothing at all. An indicator whose entire output is a table plots no values, and inheriting a departed oscillator's 0..100 left its pane labelled with a ladder it had no prices for.

    A manually scaled axis is left alone: the user set that range, and nothing would recompute it if it were thrown away.

    Returns void

  • Manually scale the visible range around its centre. factor > 1 widens the range (compress / zoom out), < 1 narrows it (expand / zoom in). Switches the scale to manual mode so autoscale stops overriding it.

    Parameters

    • factor: number

    Returns void

  • Scale around a screen coordinate, retaining its price in every scale mode.

    Parameters

    • y: number
    • factor: number

    Returns void

  • Set the baseline the rebasing modes (percentage, indexed-to-100) quote against. Ignored by linear and logarithmic.

    The baseline is data, not geometry, so the scale cannot find it alone: the autoscale pass supplies the first value of the visible range each frame. That is what makes panning re-base, so the axis always reads as change measured from the left edge of what is on screen.

    Pass null when there is nothing to measure (no series, no visible bars). A rebasing mode without a baseline falls back to the identity transform and behaves exactly like linear, rather than answering confidently with nonsense before the first frame.

    Note what a rebase does not do: it is affine over a range held in price units, so it relabels the pane rather than reshaping it. One series looks the same as it does on a linear scale, by definition (percent change is a straight-line function of price). Two instruments become comparable when each sits on its own scale with its own baseline, which is the overlay mechanism, not a second transform here.

    Parameters

    • value: null | number

    Returns void

  • Declare the range this scale must hold, or pass null to withdraw it.

    It is what an indicator that owns its pane asks for (RSI 0..100, a signal line -1..1): a band whose meaning is in the numbers themselves, so fitting it to the values on screen would destroy the reading rather than improve it. The scale goes manual while one is held, because the range is declared and not measured, and setAutoScale(true) returns to it.

    Withdrawing (null) leaves the range where it is; the caller decides whether the scale goes back under autoscale, because it is the one that knows whether anything is left on the pane to measure.

    Parameters

    Returns void

  • Override the numeric formatting used for axis tick labels, the last-price tag, and price-line labels (e.g. a currency or percent format). Pass null to restore the default tick-size-aware toFixed.

    Parameters

    • fn: null | (price: number) => string

    Returns void

  • Snap a price to the instrument tick size (no-op if minMove is 0).

    Parameters

    • price: number

    Returns number

  • Tick prices for the axis ladder, at most maxTicks of them. Linear and log get the nice ladder over the price range, exactly what the axis renderer used to build for itself.

    The rebasing modes need it built in label space: a nice price is an ugly percentage, and a ladder of "+3.47%, +6.94%" is not a ladder. So the nice values are chosen over the transformed range and mapped back to the prices the axis positions with.

    Parameters

    • maxTicks: number = 6

    Returns number[]