MAIDR JavaScript API
    Preparing search index...

    Function ensureContainerId

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

      MAIDR resolves a chart's selectors inside that chart, so a bare selector like "rect.bar" does not reach another chart's marks there. By stamping the container with a stable id and prefixing all emitted selectors with #<id>, each selector names this chart's marks alone wherever it is read, 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).