toEmbeddedHTML

fun toEmbeddedHTML(figure: Figure): String(source)

Produces an embeddable HTML fragment from a Figure — a <div> and inline <script> with no surrounding page structure. The caller is responsible for loading the Lets-Plot JS library once in the enclosing page's <head> via PlotHtmlHelper.scriptUrl.

This used to return what toSelfContainedHTML now returns: a complete document, <html>, <head>, <body> and its own library script. A report embedding several plots therefore emitted one document per plot inside the page document. Browsers recover from that — the plots render and the parsed DOM comes out right — but the markup is invalid, every plot container ends up holding the flattened head of its nested document, and the function could not be used for the one thing it exists for.