MAIDR Documentation - v3.65.0
    Preparing search index...

    Function ensureContainerId

    • Ensures a container element has an id attribute, generating one when missing. Returns the (possibly newly assigned) id.

      MAIDR resolves layer selectors via document.querySelector, which is page-global — a bare selector like "rect.bar" would collide with any other chart on the page. By stamping the container with a stable id and prefixing all emitted selectors with #<id>, we guarantee page-wide uniqueness without requiring users to set the id themselves.

      Idempotent: re-calling on a container that already has an id is a no-op.

      Parameters

      • container: Element

        The root SVG container (or any element).

      Returns string

      The container's id (existing or newly generated).