MAIDR JavaScript API
    Preparing search index...

    Class Subplot

    Interface for plot traces that support keyboard navigation and movement.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    observers: Observer<SubplotState>[]
    isWarning: boolean
    isComputingStateAt: boolean

    True while AbstractTrace.getStateAt computes state at a temporarily moved cursor. Enforces (structurally, not just by documentation) that state getters never notify observers.

    movable: Movable
    traces: Trace[][]
    traceTypes: string[]
    primaryTitle: string

    Title of the subplot's first layer, used as the subplot title in description summaries. Empty string when no layer title was provided.

    Accessors

    • get isInitialEntry(): boolean

      Returns boolean

    • set isInitialEntry(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get row(): number

      Returns number

    • set row(value: number): void

      Parameters

      • value: number

      Returns void

    • get col(): number

      Returns number

    • set col(value: number): void

      Parameters

      • value: number

      Returns void

    • get activeTrace(): Trace | null

      Gets 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.

      Returns Trace | null

      The active trace, or null when the subplot has no layers.

    • get activeLayerIndex(): number

      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.

      Returns number

    • get axesElement(): SVGElement | null

      Returns 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.

      Returns SVGElement | null

      The axes SVGElement, or null if not resolved.

    Methods

    • 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.

      Parameters

      • action: () => void

        The moves to make in silence

      Returns void

    • Gets safe row and column indices to prevent accessing undefined values

      Returns { row: number; col: number }

      Object with safe row and column indices

    • Base implementation of navigation in HIGHER and LOWER modes of ROTOR, default is no-op Needs to be implemented in Line, Bar, Heatmap, Candlestick

      Parameters

      • _direction: "left" | "right" | "up" | "down"
      • _type: "lower" | "higher"

      Returns boolean

    • Parameters

      • a: number

        Utility function to compare point values for rotor functionality

      • b: number
      • type: "lower" | "higher"

      Returns boolean

      boolean value

    • Rotor 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.

      Parameters

      • rowValues: readonly number[]

        The values of the row being searched

      • direction: "left" | "right"

        Which way to search

      • type: "lower" | "higher"

        Whether a lower or a higher value is sought

      Returns boolean

      True when a matching value was found and moved to

    • Moves up in rotor mode, optionally filtering by lower or higher values.

      Parameters

      • Optional_mode: "lower" | "higher"

        Optional mode for filtering (lower or higher)

      Returns boolean

      Error always - subclasses must override this method

    • Moves down in rotor mode, optionally filtering by lower or higher values.

      Parameters

      • Optional_mode: "lower" | "higher"

        Optional mode for filtering (lower or higher)

      Returns boolean

      Error always - subclasses must override this method

    • Moves left in rotor mode, optionally filtering by lower or higher values.

      Parameters

      • Optional_mode: "lower" | "higher"

        Optional mode for filtering (lower or higher)

      Returns boolean

      Error always - subclasses must override this method

    • Moves right in rotor mode, optionally filtering by lower or higher values.

      Parameters

      • Optional_mode: "lower" | "higher"

        Optional mode for filtering (lower or higher)

      Returns boolean

      Error always - subclasses must override this method

    • 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 boolean

    • 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 string

    • 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.

      Parameters

      • _x: number

        Screen-space x position of the pointer/finger

      • _y: number

        Screen-space y position of the pointer/finger

      Returns PointerGuidanceState | null

      Guidance state, or null when unavailable

    • Gets the number of traces in the subplot

      Returns number

      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.

      Parameters

      Returns boolean

    • 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.

      Parameters

      Returns boolean

      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.

      Parameters

      Returns Trace | null

      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.

      Parameters

      • index: number

        Zero-based layer index within the subplot

      Returns Trace | null

      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.

      Returns LayerSummary[]

    • 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.

      Returns void

    • Gets the subplot state with figure position context

      Parameters

      • _figureRow: number

        The row position in the figure

      • _figureCol: number

        The column position in the figure

      Returns SubplotState

      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.

      Returns SVGElement | null

      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.

      Returns string | null

      The selector string, or null if unavailable.

    • Sets the pre-resolved axes element for this subplot. Called by Figure.applyLayout during initialization.

      Parameters

      • element: SVGElement | null

        The axes SVGElement to store.

      Returns void