Documentation menu

Class

FerroPlot

A plot with numeric, category or date axes on a <canvas>: lines, areas, scatter, bars, waterfalls and heatmaps.

Static methods

FerroPlot.create

static create(canvas: HTMLCanvasElement, options?: PlotCreateOptions): Promise<FerroPlot>;

Creates a plot drawing into canvas, which is sized by CSS (the backing store follows its CSS size × devicePixelRatio).

Properties

renderer

readonly renderer: 'webgpu' | 'webgl2';

The GPU API in use: 'webgpu' or 'webgl2'.

Methods

addLabel

addLabel(options: LabelOptions): Label;

Adds a text or symbol at data coordinates.

addMark

addMark(kind: MarkKind, options?: MarkOptions): Mark;

Adds a mark drawn above the earlier ones.

addRule

addRule(options: RuleOptions): Rule;

Adds a line across the plot at a value, or a shaded band.

axis

axis(name: AxisName): Axis;

An axis: 'x', 'left' (hidden by default) or 'right'.

destroy

destroy(): void;

Removes all listeners and releases the GPU resources. The object can no longer be used. (The same as FerroChart.destroy.)

dispose

dispose(): void;

The former name of destroy, kept for existing code.

finishIntro

finishIntro(): void;

Ends the intro animation now, showing everything.

fit

fit(): void;

Shows all data: automatic axes follow the data again.

playIntro

playIntro(options?: IntroOptions): Promise<void>;

Intro animation, as FerroChart.playIntro: empty plot area and axes at once, then the marks drawn from left to right; rule labels and the hover appear at the end.

setAttributionLogo(on: boolean): void;

Shows or removes the attribution logo (see attributionLogo).

on

on<K extends keyof PlotEventMap>(event: K, callback: (event: PlotEventMap[K]) => void): void;

Subscribes to an event of PlotEventMap. Events are delivered after the frame that produced them. An exception thrown by the callback is reported (reportError, shown in the console) and does not stop the other callbacks.

off

off<K extends keyof PlotEventMap>(event: K, callback: (event: PlotEventMap[K]) => void): void;

Removes a callback added with on.

Like every object of the API, a FerroPlot holds WebAssembly memory. Objects returned by the chart are freed with it; free() (or using) releases one earlier.