Interface: TracePlotContext<Calc>
Experimental
Everything a trace renderer may use. A fresh context is passed to every call.
Type Parameters
| Type Parameter | Default type |
|---|---|
Calc | unknown |
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
calc | readonly | Calc | Experimental |
cells? | readonly | readonly 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? | readonly | DomainInfo | Experimental 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. |
fullLayout | readonly | FullLayout | Experimental |
index | readonly | number | Experimental Index of the trace in data; also its draw order. |
plotArea? | readonly | Readonly<ViewportRect> | Experimental The plot area inside the margins, container px (M2 wave 1). Always set by the runtime. |
primitives | readonly | PrimitiveContext | Experimental Pass to primitive factories (createMarkers(ctx.primitives, …)). |
selectedPoints? | readonly | readonly number[] | null | Experimental 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. |
subplot | readonly | SubplotInfo | undefined | Experimental The trace's subplot (cartesian traces only). |
trace | readonly | FullTrace | Experimental The defaulted trace. |
transform | readonly | Readonly<DataTransform> | Experimental Linear coordinates → viewport world px (identity for non-cartesian traces). |
viewport | readonly | Viewport | Experimental Where the trace draws: its subplot's viewport, or the overlay for non-cartesian traces. |
xaxis | readonly | AxisInfo | undefined | Experimental |
yaxis | readonly | AxisInfo | undefined | Experimental |
Methods
add()
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
| Parameter | Type |
|---|---|
primitive | Primitive<T> |
viewport? | Viewport |
Returns
Primitive<T>
invalidate()
invalidate(): void;Experimental
Schedule a frame (ADR-007), e.g. after async resources finish loading.
Returns
void
recalc()?
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()
remove<T>(primitive): void;Experimental
Remove (and dispose) a primitive added with add.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
primitive | Primitive<T> |
Returns
void
subplotViewport()?
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
| Parameter | Type |
|---|---|
key | string |
options | SubplotViewportOptions |