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.
Ensures a container element has an
idattribute, 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.