Paints one pane's series. One instance per pane: a backend holds a context on that pane's base canvas, and contexts do not travel between canvases.

interface IRenderBackend {
    device?: RenderDevice;
    kind: RenderBackendKind;
    beginFrame(clear: boolean): void;
    destroy(): void;
    drawSeries(
        entry: RendererEntry,
        items: readonly DrawItem[],
        priceToY: (price: number) => number,
        barSpacing: number,
        dpr: number,
        style: SeriesStyle,
        rc: SeriesRenderContext,
    ): void;
    endFrame(): void;
    mount(
        canvas: HTMLCanvasElement,
        ctx2d: null | CanvasRenderingContext2D,
    ): void;
    overlay2d(): null | CanvasRenderingContext2D;
    resize(widthPx: number, heightPx: number, dpr: number): void;
}

Implemented by

Properties

device?: RenderDevice

The GPU device behind the backend, when it has one. The chart reads it after a frame (backendDegradation) to learn that the context has been lost or never came up, and moves every pane to canvas2d for the rest of the session, announced by the 'renderer:fallback' chart event. A backend without a device is never degraded, so the 2D backend leaves it unset.

Methods

  • Start a frame on the base canvas, clearing it first when asked.

    Parameters

    • clear: boolean

    Returns void

  • Release the context and any GPU resources. The pane removes the canvas.

    Returns void

  • Take the pane's base data canvas. ctx2d is the 2D context the pane already holds on it, when it holds one: the canvas-2D backend draws on exactly that object, so a frame is one context's op stream and not two contexts' interleaved. A backend that owns the canvas outright ignores it.

    Parameters

    • canvas: HTMLCanvasElement
    • ctx2d: null | CanvasRenderingContext2D

    Returns void

  • A 2D context for what the backend does not draw natively (grid, axes, primitives), or null when the backend paints those itself.

    Returns null | CanvasRenderingContext2D

  • The pane's media size and pixel ratio changed. Sizes in CSS px.

    Parameters

    • widthPx: number
    • heightPx: number
    • dpr: number

    Returns void