Observable’s rules for SVG detection are:
- top level element is instance of
SVGSVGElement
OR - top level element contains exactly one
svg
element (at any level) AND- svg fills at least 75% of top level element’s width OR
- svg fills at least 75% of top level element’s height
Equivalent conditions apply to canvas detection.
Graphviz plots fail these tests because they nest See next answer.svg
elements.
@mbostock I think Observable’s detection could be improved by not counting SVG that are nested inside other SVGs.