Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Class ColormapLegend

    Bottom-right overlay listing each visible layer's colormap gradient, name, and data range (toggled with the J key). Subscribes to the LayerStateManager and rebuilds its entries reactively, but only re-renders the DOM when the visible layers, their colormaps, or their data ranges (displayMin/displayMax) actually change (guarded by a cheap content hash over those fields).

    Hierarchy (View Summary)

    Index
    unsubscribe?: () => void
    lastHash: string = ''
    element: HTMLElement
    • Render the component DOM structure. Should return a root element with appropriate class names. NO INLINE STYLES - use CSS classes only!

      Returns HTMLElement

      Root element for this component

    • Rebuild the legend entries. Only rebuilds DOM if the set of visible layers+colormaps has changed.

      Returns void

    • Add an event listener with automatic cleanup tracking. Prevents memory leaks - all listeners removed on dispose()!

      IMPORTANT: Use arrow functions for event handlers to maintain component context:

      private handleClick = (ev: MouseEvent) => {
      // 'this' refers to component instance
      this.someMethod();
      };

      protected attachEventListeners(): void {
      this.addEventListener(this.element, 'click', this.handleClick);
      }

      Type Parameters

      • K extends keyof HTMLElementEventMap

      Parameters

      • target: EventTarget

        Event target (element, window, document, etc.)

      • type: K

        Event type ('click', 'keydown', etc.)

      • listener: (ev: HTMLElementEventMap[K]) => void

        Event listener function (should be arrow function)

      • Optionaloptions: AddEventListenerOptions

        Optional event listener options

      Returns void

    • Add a generic event listener (for non-standard events)

      Parameters

      • target: EventTarget

        Event target

      • type: string

        Event type (string for custom events)

      • listener: EventListener

        Event listener function

      • Optionaloptions: AddEventListenerOptions

        Optional event listener options

      Returns void

    • Dispose the component - cleanup all resources. NO MORE MEMORY LEAKS!

      Automatically:

      • Removes all tracked event listeners
      • Unsubscribes from theme changes
      • Calls onDispose() for custom cleanup
      • Removes element from DOM

      Returns void