Just a little proof-of-concept here - using an SVG <foreignObject>
element as a container for a tooltip that can involve handy HTML features like text-wrapping and (semi-)dynamic sizing.
Gotchas so far:
-
Like an
<svg>
element, a<foreignObject>
element needs a width and a height in order to be rendered. -
However, specifying
width
and/orheight
can be delayed. Here I specify a width (foWidth
) of 300px, then find the height of the contained<div>
usinggetBoundingClientRect()
and use that to specify the height of the containing<foreignObject>
.