Creates a new Subplot instance from MAIDR subplot data
The MAIDR subplot data containing layers
Protected ReadonlyobserversProtectedisProtectedisTrue while AbstractTrace.getStateAt computes state at a temporarily moved cursor. Enforces (structurally, not just by documentation) that state getters never notify observers.
Protected ReadonlymovableReadonlytracesReadonlytraceReadonlyprimaryTitle of the subplot's first layer, used as the subplot title in description summaries. Empty string when no layer title was provided.
ProtecteddimensionProtectedvaluesGets the currently active trace based on row and column position.
Nullable because a subplot is allowed to have no layers at all: producers
legitimately emit layers: [] for an unoccupied grid cell in a
non-rectangular layout, or for a panel whose geom MAIDR does not support
yet. Callers must treat null as "this panel has nothing to describe"
rather than assume a trace is always there — before this was nullable, an
empty layers array threw here during figure construction and left the
whole figure inert.
The active trace, or null when the subplot has no layers.
Index of the active layer within the subplot.
Traces are constructed as one single-trace row per layer
(traces[layerIndex][0]), so the active trace row IS the layer index.
This accessor makes that invariant explicit for callers (e.g. the
Controller's sliding-window cursor tracking) instead of having them
depend on the internal layout.
ProtectedoutReturns the pre-resolved parent <g id="axes_*"> element for this subplot.
This is set externally via setAxesElement during layout resolution
and does not perform any DOM queries.
The axes SVGElement, or null if not resolved.
Runs action with this element's observers muted.
A cursor move normally is the announcement -- moveToIndex notifies, and
everything downstream of it speaks, brailles and highlights. That is wrong
for a move the reader did not make and is not waiting to hear: the
description dialog's layer tabs relocate the reader in the chart while the
modal is open, and the trace's announcement would land in the same live
region the dialog is using, so one of the two is dropped. The caller
announces afterwards, once, when the reader is back on the chart.
Nesting is safe and the flag is restored on every path, including a throw, because a flag left raised would silence the chart for good.
The moves to make in silence
ProtectedgetGets safe row and column indices to prevent accessing undefined values
Object with safe row and column indices
Registers an observer to receive state updates.
The observer to add
Removes an observer from receiving state updates.
The observer to remove
Notifies all registered observers with the current state.
Notifies observers that an out-of-bounds condition occurred.
Base implementation of navigation in HIGHER and LOWER modes of ROTOR, default is no-op Needs to be implemented in Line, Bar, Heatmap, Candlestick
Utility function to compare point values for rotor functionality
boolean value
ProtectedcompareRotor compare search along one row of numeric values.
Steps from the current column in the given direction and moves to the first value that satisfies the comparison; reports the rotor boundary when nothing further qualifies. For the traces whose values are a plain numeric grid indexed [row][col]; a trace with a richer layout (the bar's orientation-normalised rows, the candlestick's segments) keeps its own.
The values of the row being searched
Which way to search
Whether a lower or a higher value is sought
True when a matching value was found and moved to
Returns true if this trace supports compare (lower/higher value) navigation. Override to false for trace types that don't use compare modes (e.g., scatter, which is all we currently have).
Returns the display name for the default data navigation mode. Override to provide a trace-specific name (e.g., "ROW AND COLUMN NAVIGATION" for scatter).
Returns the rotor's compare-mode labels and boundary-message nouns. Override to rename the two compare units for a trace-specific semantic (e.g., the candlestick delta layer uses "above line" / "below line").
Moves the active point to the (x, y) pointer location and returns directional guidance toward the nearest data geometry.
Combines navigation and guidance into a single call so traces compute
findNearestPoint only once per pointer event. Default returns null
for non-trace contexts.
Screen-space x position of the pointer/finger
Screen-space y position of the pointer/finger
Guidance state, or null when unavailable
Gets the number of traces in the subplot
The size (number of traces)
Override moveOnce to avoid "initial entry" no-op behavior for layer navigation.
For multi-layer subplots, the MovableGrid is used to step between layers (traces). We don't want the first PageUp/PageDown to be eaten by handleInitialEntry; instead, it should actually switch layers.
Steps the active layer without notifying observers.
A layer switch is announced from the newly positioned trace (see switchLayer). A subplot notification at this point would describe the new trace at whatever column it was left on, before X-preservation has moved it. Like moveOnce, the first step on a multi-layer subplot is a real step rather than the initial-entry no-op.
The direction to step in
True when the active layer changed
Switches to the adjacent layer, carrying the reader's position across and announcing the result once.
The whole layer switch, as opposed to stepLayer's bare cursor
step: it preserves X (and Y where both traces support it), reports the
boundary when there is no adjacent layer, and notifies from the trace once
it is positioned. Context.stepTrace is the caller, and swaps the trace at
the top of its stack for whatever comes back.
The direction to switch in
The newly active trace (the same one at a boundary), or null when the subplot has no layer to read
Makes the layer at index the active one, carrying the reader's position
across the same way a PageUp/PageDown step does -- and announcing nothing.
The silence is the point: this is the jump the chart description's layer tabs make while the modal is open, and the trace's own announcement there would talk over the dialog. The caller decides when the reader is told; switchLayer is still the announcing path for the keyboard.
Zero-based layer index within the subplot
The newly active trace, the current one when index already is
the active layer, or null when the subplot has no layer to read or the
index is out of range.
At-a-glance summaries of every layer in this subplot, in layer order.
Built for the chart description's layer tabs, which need to name the layers a reader can switch to before they switch to one. Returns an empty array for a single-layer subplot: there is no choice to offer, and the dialog omits the tab strip entirely.
The type label is the same AbstractTrace.chartTypeLabel the description's own "Chart Type" line uses, so a tab and the panel it opens name the chart the same way.
Announces the active layer as a layer switch, for a switch that was made in silence and is being spoken later.
selectLayer is the silent move -- the description dialog's layer tabs -- and this is how its caller tells the reader where they ended up, once, on the way out of the dialog. Nothing else differs: it is the same "Layer 2 of 3" announcement, over the same observer chain, that a PageUp/PageDown step makes for itself.
Gets the subplot state with figure position context
The row position in the figure
The column position in the figure
The subplot state
Returns the subplot's own SVG highlight element (resolved from subplot.selector).
Used by the layout utility to locate the parent axes group.
The SVG element, or null if the subplot has no selector.
Returns the CSS selector string from the first layer of this subplot.
Used as a fallback by the layout utility when getHighlightElement() is null.
The selector string, or null if unavailable.
Sets the pre-resolved axes element for this subplot. Called by Figure.applyLayout during initialization.
The axes SVGElement to store.
Interface for plot traces that support keyboard navigation and movement.