MAIDR JavaScript API
    Preparing search index...

    Interface Trace

    Interface representing a trace with navigation and observation capabilities

    interface Trace {
        getId: () => string;
        traceType: TraceType;
        layerLabel: string;
        level: "trace";
        runSilently: (action: () => void) => void;
        getCurrentXValue: () => any;
        moveToXValue: (xValue: any) => boolean;
        getCurrentYValue?: () => number | null;
        moveToXAndYValue?: (xValue: any, yValue: number) => boolean;
        notifyOutOfBounds: () => void;
        resetToInitialEntry: () => void;
        getStateAt: (row: number, col: number) => TraceState;
        notifyObserversWithState: (state: TraceState) => void;
        getAllHighlightElements: () => SVGElement[];
        getAllOriginalElements: () => SVGElement[];
        getGeometryElements?: () => SVGElement[];
        moveToPointAndGetPointerGuidance: (
            x: number,
            y: number,
        ) => PointerGuidanceState | null;
        getExtremaTargets?: () => ExtremaTarget[];
        navigateToExtrema?: (target: ExtremaTarget) => void;
        dispose: () => void;
        moveOnce: (direction: MovableDirection) => boolean;
        moveToExtreme: (direction: MovableDirection) => boolean;
        moveToIndex: (row: number, col: number) => boolean;
        isMovable: (target: MovableDirection | [number, number]) => boolean;
        get isInitialEntry(): boolean;
        set isInitialEntry(value: boolean): void;
        get row(): number;
        set row(value: number): void;
        get col(): number;
        set col(value: number): void;
        addObserver: (observer: Observer<TraceState>) => void;
        removeObserver: (observer: Observer<TraceState>) => void;
        notifyStateUpdate: () => void;
        get state(): T;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    getId: () => string

    Gets the unique identifier for the trace

    Type Declaration

      • (): string
      • Returns string

        The trace ID

    traceType: TraceType

    The trace's chart type, exposed without computing the full state.

    layerLabel: string

    How the layer names itself in the chart description's layer tabs — the producer's name when there is one, and the chart-type label otherwise. Exposed here for the same reason Trace.traceType is: the tab strip names every layer of a subplot, including the ones the reader has not visited, and building each one's full state to read a label would compute an audio, braille, text and highlight snapshot per layer per keypress.

    level: "trace"

    Which level of the figure this element is, for the same reason Trace.traceType exists: state.type answers it too, but only after building the whole audio/braille/text/highlight snapshot.

    runSilently: (action: () => void) => void

    Runs the given moves with this trace's observers muted, so a relocation the reader did not ask for does not announce itself. See AbstractPlot.runSilently.

    getCurrentXValue: () => any

    Gets the current X value from the trace

    Type Declaration

      • (): any
      • Returns any

        The current X value or null if not available

    moveToXValue: (xValue: any) => boolean

    Moves the trace to the position that matches the given X value

    Type Declaration

      • (xValue: any): boolean
      • Parameters

        • xValue: any

          The X value to move to

        Returns boolean

        True if the position was found and set, false otherwise

    getCurrentYValue?: () => number | null

    Get the current Y value from the trace. Optional method implemented by traces that support Y value preservation during layer switching.

    Type Declaration

      • (): number | null
      • Returns number | null

        The current Y value or null if not available

    moveToXAndYValue?: (xValue: any, yValue: number) => boolean

    Move to a specific X value and find the closest position with the given Y value. Optional method implemented by traces that support preserving both X and Y values during layer switching.

    Type Declaration

      • (xValue: any, yValue: number): boolean
      • Parameters

        • xValue: any

          The X value to move to

        • yValue: number

          The Y value to find the closest matching position for

        Returns boolean

        true if the move was successful, false otherwise

    notifyOutOfBounds: () => void

    Notify observers that the trace is out of bounds

    resetToInitialEntry: () => void

    Resets the trace to initial entry state

    getStateAt: (row: number, col: number) => TraceState

    Computes the trace state at an arbitrary position without moving the cursor or notifying observers (used by monitor mode).

    Type Declaration

      • (row: number, col: number): TraceState
      • Parameters

        • row: number

          The row of the position to compute state for

        • col: number

          The column of the position to compute state for

        Returns TraceState

        The trace state at the requested position

    notifyObserversWithState: (state: TraceState) => void

    Notifies all observers with a specific state

    Type Declaration

      • (state: TraceState): void
      • Parameters

        • state: TraceState

          The trace state to send to observers

        Returns void

    getAllHighlightElements: () => SVGElement[]

    Get all highlight SVG elements for this trace Used by HighlightService for high contrast mode

    Type Declaration

      • (): SVGElement[]
      • Returns SVGElement[]

        Array of all SVG elements, or empty array if none

    getAllOriginalElements: () => SVGElement[]
    getGeometryElements?: () => SVGElement[]

    The elements whose geometry is the trace as the chart drew it, when that differs from the highlight elements.

    Optional, and empty rather than absent when a trace has nothing extra to offer, so a caller can fall back to the highlight elements in one check. Implemented by traces whose highlight markers stand in for a shape rather than being it -- a line whose per-point circles maidr synthesised from the rendered <path>, where the path is the geometry and the circles are only the vertices on it.

    Type Declaration

      • (): SVGElement[]
      • Returns SVGElement[]

        The drawn elements, or an empty array when there are none

    moveToPointAndGetPointerGuidance: (
        x: number,
        y: number,
    ) => PointerGuidanceState | null

    Moves to the nearest point at (x, y) and returns directional guidance toward the nearest data geometry in a single call. Combining the two operations avoids running findNearestPoint twice per pointer event.

    For ViolinKdeTrace, coordinates map to (violin index, y-value within KDE curve); for ViolinBoxTrace, to (section index, violin index) for vertical orientation, or the inverse for horizontal.

    Type Declaration

      • (x: number, y: number): PointerGuidanceState | null
      • Parameters

        • x: number

          Screen-space x position in viewport pixels

        • y: number

          Screen-space y position in viewport pixels

        Returns PointerGuidanceState | null

        Guidance state, or null when unavailable for this plot level

    getExtremaTargets?: () => ExtremaTarget[]

    Gets extrema targets for navigation. Optional method implemented by traces that support extrema navigation.

    Type Declaration

    navigateToExtrema?: (target: ExtremaTarget) => void

    Navigate to a specific extrema target. Optional method implemented by traces that support extrema navigation.

    Type Declaration

    dispose: () => void
    moveOnce: (direction: MovableDirection) => boolean
    moveToExtreme: (direction: MovableDirection) => boolean
    moveToIndex: (row: number, col: number) => boolean
    isMovable: (target: MovableDirection | [number, number]) => boolean
    addObserver: (observer: Observer<TraceState>) => void
    removeObserver: (observer: Observer<TraceState>) => void
    notifyStateUpdate: () => void

    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