HOSTING

Share a Vega-Lite chart as a link

A Vega-Lite chart is a JSON spec that vega-embed draws in the browser, so it fits in one HTML file. Load the three libraries from a CDN, put the data in the spec as values, upload the file, and send a link that opens the interactive chart.

4 min read·

A Vega-Lite spec needs a page to run in. Sending the .json spec means the recipient needs the Vega Editor or a notebook to see anything, and a screenshot drops tooltips, selections and zoom.

One HTML file that loads Vega, Vega-Lite and vega-embed from a CDN and holds the spec and its data, hosted at a link, opens the working chart on any device.

Put the chart in one file

Create chart.html with this structure:

  • ✓<!doctype html>, <meta charset="utf-8"> and <meta name="viewport" content="width=device-width, initial-scale=1"> in the head.
  • ✓Three script tags, in this order: https://cdn.jsdelivr.net/npm/vega@6.4.0, https://cdn.jsdelivr.net/npm/vega-lite@6.5.0 and https://cdn.jsdelivr.net/npm/vega-embed@7.3.0. Pinning the versions keeps the chart from changing when a new release ships.
  • ✓A container: <div id="chart"></div>.
  • ✓A <script> block after the container that defines the spec and calls vegaEmbed("#chart", spec).
  • ✓Set "width": "container" in the spec and the chart takes the width of the page, so the same file fits a phone screen.

Keep the data inside the spec

A spec with "data": { "url": "data.csv" } requests a second file. An uploaded page is hosted on its own, so that request fails and the chart draws empty axes or nothing.

Put the rows in the spec instead: "data": { "values": [{ "month": "Jan", "signups": 12 }, { "month": "Feb", "signups": 19 }] }. Tested on Vega-Lite 6.5.0 with vega-embed 7.3.0: a three-row values array drew three bars.

Data that already lives at a public URL which allows cross-origin requests can stay as a url with the full https:// address.

An Altair chart is a Vega-Lite spec too. chart.save("chart.html") writes this kind of file for you: sharing a Bokeh or Altair chart.

Upload it and send the link

Drag the .html file onto the FileShare Pro dashboard and copy the link. The chart draws when the page opens. Tooltips ("tooltip": true on the mark), selections and pan and zoom work as they did locally, and viewers need no account.

vega-embed adds a small menu to the chart for saving it as an image and viewing the spec. To hide it, call vegaEmbed("#chart", spec, { actions: false }).

If the page is blank once hosted, open the browser console. "vegaEmbed is not defined" means a script tag is missing or comes after your chart code; a failed request for a .csv or .json file means data was left outside the page. Why an AI page works in chat but breaks when hosted covers charts an assistant wrote.

Turn on comments and viewers can leave a note on the page after typing a name. When the numbers change, upload the new file over the old one and the link stays the same: updating a shared link without changing it.

Other chart libraries: Observable Plot, Highcharts, ECharts, Chart.js, Plotly, D3.

Frequently asked

How do I share a Vega-Lite chart without a web server?

Put script tags for Vega, Vega-Lite and vega-embed from a CDN, a container, your spec with the data as values, and a vegaEmbed() call into one HTML file. Upload it to a host that serves HTML as a web page and send the link.

Why is my Vega-Lite chart empty after upload?

Usually the spec loads data from a file with "url" that was not uploaded with the page. Move the rows into "values", or point "url" at a public https:// address that allows cross-origin requests.

Can I hide the three-dot menu vega-embed adds?

Yes. Pass { actions: false } as the third argument to vegaEmbed().

Is it free?

Yes. The free plan hosts up to 50 files of up to 100 MB each, with view counts and comments included. Password-protected links are on Pro.

Got a page to share?

Drop the file, copy the link — live in seconds, free plan included.

Start sharing free