When using JS to render a vega-lite
chart that was originally built in Python (using altair
), the default is to allow a variety of options on the chart itself: save as image, view source, and Open in Vega Editor.
Using this method, we can modify those options by adjusting the vega-embed
"actions" option:
"actions": {"editor": false}
Eg:
var spec = JSON.parse({{ graph_json|tojson }})
var opt = { /* Options for the embedding */
"renderer": "canvas",
"actions": {
"export": true, /* "Save as PNG|SVG" */
"source": true, /* "View Source" */
"compiled": true, /* "View Vega Source" */
"editor": false /* Do not allow export to https://vega.github.io/editor */
}
};
vegaEmbed("#vis", spec, opt);
However, when using altair
in a colab / Jupyter Notebook, we don't have access to that JS. Is there a way to modify those options using altair
directly?
I was thinking there might be a renderer option, but I haven't been able to find anything. Perhaps there's a way to customize the colab renderer?
Alternatively, how about setting editorUrl
?
But why do I want to do this?
TL;DR: Data exfiltration risk.
Disabling those "Show Source" and "Editor" buttons is one part of data exfil protection. Using a self-hosted editor instead of the default github one is another acceptable method.