Skip to content

Interface: TracePlotContext<Calc> ​

Experimental

Everything a trace renderer may use. A fresh context is passed to every call.

Type Parameters ​

Type ParameterDefault type
Calcunknown

Properties ​

PropertyModifierTypeDescription
calcreadonlyCalcExperimental
cells?readonlyreadonly SubplotInfo[]Experimental Multi-subplot traces (M3 wave 2, E10.9; see TraceModule.cells): the subplots of the trace's cells that exist, in the order cells listed them. Each has its own viewport, axes and transform; add a cell's primitives with add(primitive, cell.viewport). subplot, xaxis and yaxis are undefined for such traces, and viewport is the overlay. Zooming or panning any cell's axes sends a transform update with the new transforms here.
domain?readonlyDomainInfoExperimental The trace's domain (M2 wave 1, E4.5): set for traces in the domain category, which draw into the overlay (see DomainInfo); undefined for every other trace.
fullLayoutreadonlyFullLayoutExperimental
indexreadonlynumberExperimental Index of the trace in data; also its draw order.
plotArea?readonlyReadonly<ViewportRect>Experimental The plot area inside the margins, container px (M2 wave 1). Always set by the runtime.
primitivesreadonlyPrimitiveContextExperimental Pass to primitive factories (createMarkers(ctx.primitives, …)).
selectedPoints?readonlyreadonly number[] | nullExperimental Active selection for this trace (E6.3): indices into its data arrays, or null when nothing is selected (draw everything normally). Traces apply selected / unselected styles from it.
subplotreadonlySubplotInfo | undefinedExperimental The trace's subplot (cartesian traces only).
tracereadonlyFullTraceExperimental The defaulted trace.
transformreadonlyReadonly<DataTransform>Experimental Linear coordinates → viewport world px (identity for non-cartesian traces).
viewportreadonlyViewportExperimental Where the trace draws: its subplot's viewport, or the overlay for non-cartesian traces.
xaxisreadonlyAxisInfo | undefinedExperimental
yaxisreadonlyAxisInfo | undefinedExperimental

Methods ​

add() ​

ts
add<T>(primitive, viewport?): Primitive<T>;

Experimental

Add a primitive to the trace's viewport, or to viewport (a cell's, M3 wave 2). The runtime tracks it: it is reported by chart.getTraceObjects(i) and removed and disposed with the view.

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
primitivePrimitive<T>
viewport?Viewport

Returns ​

Primitive<T>


invalidate() ​

ts
invalidate(): void;

Experimental

Schedule a frame (ADR-007), e.g. after async resources finish loading.

Returns ​

void


recalc()? ​

ts
optional recalc(): void;

Experimental

Run this trace's calc again in the chart's next pipeline run, without a change to the figure: what the view was waiting for has arrived (backlog G7: the layout of a graph from a worker), and calc now returns another result. The run is a calc update of the trace like any other (autorange, update with plan.calc), and update promises that have not resolved yet wait for it, as they do for a pass a component asked for. Always set by the runtime; optional for hand-built contexts.

Returns ​

void


remove() ​

ts
remove<T>(primitive): void;

Experimental

Remove (and dispose) a primitive added with add.

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
primitivePrimitive<T>

Returns ​

void


subplotViewport()? ​

ts
optional subplotViewport(key, options): Viewport;

Experimental

The 3D viewport of non-cartesian subplot key (M6: a 3D scene, 'scene', 'scene2', …; ADR-004): its own rect, perspective or orthographic camera and depth buffer (cleared first), drawn after the cartesian subplots and before the overlay. Created on the first call, shared by every trace and component that asks for the same key and updated with options on each call; removed (with what is still in it) after a draw pass in which nothing asked for it. Add primitives to it with add(primitive, viewport). Always set by the runtime; optional for hand-built contexts.

Parameters ​

ParameterType
keystring
optionsSubplotViewportOptions

Returns ​

Viewport

Released under the MIT License.