@rekurt/openkline - v0.2.0
    Preparing search index...

    Class RegressionChannel

    Linear-regression channel — two anchor points delimiting an index span. A least-squares line is fitted to the close values inside the span (the central line); parallel ±k·σ boundaries (k = 2 by default, the conventional regression-channel width) bracket it.

    Data access: Drawing.render(ctx, layout, viewport, theme) has no candle buffer by design (anchors are the single source of truth for every other drawing). Rather than widen that signature, the channel keeps its own samples array — the closes of its span — populated once via a CloseSampler the host attaches at creation, or via setSamples/snapshot restore. The samples persist in the drawing snapshot (data), so a reloaded channel reproduces the exact same fit with no buffer present.

    Anchors carry only the span (index); their price is used solely as a fallback center line when no samples are available yet (e.g. a span entirely outside the loaded buffer), so the drawing degrades to a plain segment instead of vanishing.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    color: string | null = null
    id: string
    points: AnchorPoint[] = []
    K: 2

    Band half-width in standard deviations.

    KIND: "regression" = 'regression'

    Accessors

    • get isComplete(): boolean

      True once requiredPoints clicks have been collected.

      Returns boolean

    • get isReplayCapExempt(): boolean

      True when the drawing's rendered geometry does NOT depend on its anchor index/time — e.g. a full-width horizontal price level. Such drawings stay visible (and selectable) under a replay cap even when their stored anchor index sits past the revealed prefix, because the index is cosmetic for them. Index/time-dependent drawings (the default) are hidden once every anchor is past the cap, so a not-yet-revealed shape never leaks. Subclasses whose render ignores the index override this to true.

      Returns boolean

    • get requiredPoints(): number

      How many clicks are needed before the drawing is "complete".

      Returns number

    Methods

    • Hit-test a screen point (in canvas pixels) against this drawing for selection. Returns true when the point is within tolerance pixels of the rendered geometry.

      The default implementation treats the anchors as a polyline (correct for segment shapes like TrendLine and Arrow). Shapes whose rendered geometry differs from a simple anchor polyline — full-width/height lines, rectangles, rays, channels, fib levels — override this.

      Parameters

      • px: number
      • py: number
      • layout: ChartLayout
      • viewport: Viewport
      • tolerance: number = DRAWING_HIT_TOLERANCE_PX

      Returns boolean

    • Provide the close samples directly. start is the buffer index of samples[0]. Replaces any previously sampled/cached data.

      Parameters

      • samples: number[]
      • start: number

      Returns void

    • Optional numeric payload persisted alongside the anchors. The base class emits nothing; subclasses that derive geometry from sampled data (regression channel) override this so the snapshot round-trips exactly. Mirrors restoreData.

      Returns number[] | undefined