Interactive HTML Output#
HTML output is a standalone web page that renders the chart interactively with Vega Embed. Use it when the reader needs interaction. Use SVG, PNG, JPEG, or PDF for static results.
Choose How Dependencies Load#
By default the page loads the Vega, Vega-Lite, and Vega Embed libraries from an online content delivery network (CDN). The file stays small, but the page needs network access when it opens.
Set bundle=true to include those libraries in the HTML file, along with any plugins and the fonts VlConvert resolved for the chart. The browser no longer needs to fetch these dependencies. Data and images referenced by URL, and fonts that were not embedded, may still require network access.
HTML generation normally embeds the specification without evaluating it. When Google Font discovery, an explicit Google Font request, or local font embedding is enabled, VlConvert evaluates the chart to resolve fonts. That evaluation can load external data and images under VlConvert’s access policy before the browser loads them again when the page is opened.
Choose a Browser Renderer#
renderer selects how the browser draws the chart: svg (the default), canvas for a raster mode with better performance, or hybrid, which draws text as SVG and all other marks with the canvas renderer. This option only affects the page when displayed in the browser. It does not change how VlConvert renders static formats.
The examples use the input from Quick Start:
chart.vl.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"data": {
"values": [
{"category": "A", "value": 28},
{"category": "B", "value": 55},
{"category": "C", "value": 43},
{"category": "D", "value": 91},
{"category": "E", "value": 81}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "category", "type": "nominal"},
"y": {"field": "value", "type": "quantitative"}
}
}
from pathlib import Path
import vl_convert as vlc
spec = Path("chart.vl.json").read_text(encoding="utf-8")
html = vlc.vegalite_to_html(
spec,
bundle=True,
renderer="svg",
)
Path("chart.html").write_text(html, encoding="utf-8")
The examples above generate a standalone HTML page per chart. For more flexible use cases, see JavaScript Bundling to build the browser bundle without an HTML page, and Plugin Loading and Security for how plugins are included in HTML output.