MAIDR JavaScript API
    Preparing search index...

    Class HighlightService

    Service responsible for managing visual highlighting of SVG elements in MAIDR visualizations.

    The HighlightService provides visual feedback by creating highlight overlays on chart elements when users navigate through data points. It supports both trace-level highlighting (individual data points) and subplot-level highlighting (for multi-plot scenarios).

    • Observes state changes to update highlights
    • Supports cleanup when the service is no longer needed
    const highlightService = new HighlightService(settingsService, () => [plot]);

    // Subscribe to state changes
    traceState.subscribe(highlightService);

    // Manual highlighting
    highlightService.highlight(svgElement);

    // Cleanup
    highlightService.dispose();

    Implements

    Index

    Constructors

    Methods

    • Disposes of the service by removing all active highlights. Should be called when the service is no longer needed to prevent memory leaks.

      Returns void

    • Draws the current highlight again, as the next move would: from the marks as they are painted now, in the highlight colour as it is set now.

      A highlight is a copy of its mark, taken when it is drawn. Once high contrast repaints the chart, or the highlight colour changes, the copy keeps the old palette until the reader moves: a Graphviz node's copy covered its new light outline with the old black one, and a black tile stayed on a chart put back to light. Settings are read afresh, since the change that called this may not have reached this service yet.

      Returns void

    • Observer update method called when observed state changes. Routes to appropriate handler based on state type.

      Parameters

      • state: HighlightStateUnion

        The updated state object (Settings, SubplotState, TraceState, or FigureState)

      Returns void

    • Manually highlights a single SVG element. Removes any existing highlight on the element before applying a new one.

      Parameters

      • element: SVGElement

        The SVG element to highlight

      Returns void

    • Removes the highlight from a single SVG element. Safely handles cases where the element has no active highlight.

      Parameters

      • element: SVGElement

        The SVG element to remove highlight from

      Returns void

    • Clears all active highlights from both trace elements and subplots. Use this method to reset the visual state of the visualization.

      Returns void