Hi,
i recently discovered Altair and I'm playing around with it.
It looks quite impressive and easy to use!
Under every visualization i create an Export as PNG/ View Source/ Open in Vega Editor footer is shown.
I already searched the documentation but couldn't find where to disable this "footer row".
Could anybody give me a hint how i can turn off this Footer?
Kind regards
Bernd
There is currently no way to do this. We've been talking about a model to give users control over chart metadata, but it's not implemented yet.
Hi @yashagrawal3 - this issue is a bit complicated because it requires defining a Python-side API for setting metadata, defining a way for that metadata to be passed to the frontends, and updating all the frontends to handle metadata in that format. None of those three things has been figured out yet, though #678 is one proposal for how to handle the first of the three related issues.
I'm hoping to tackle related things this week, so hopefully there will be some progress here :smile:
@bgruenefeld You can hide the chart footer by inserting <style>.vega-actions {display: none}</style> in the html.
Note: as soon as #776 is merged, there will be a better story for controlling plot metadata without manually adjusting CSS
This works now in the most recent versions of the notebook and jupyterlab renderers; you can use, e.g. for the notebook:
alt.renderers.enable('notebook', embed_options={'actions': False})
Didn't want to open a new issue about this so commenting here.
This works in the notebook, however, chart.save('viz.html') still has the footer. Is there a way to turn it off in the HTML, or should we add CSS as mentioned above?
In my specific use case, I am using a vega html export in a reveal.js slide, so I would love the HTML export to not have the footer.
Best,
Gaurav
The save() method accepts an embed_options parameter, that lets you specify this sort of thing. So, for example you could do
chart.save('viz.html', embed_options={'actions': False})
Thank you so much for the quick response Jake.
That works perfect!
The current best way to do this (Altair 4.0) is to run
alt.renderers.set_embed_options(actions=False)
which should work with any renderer.
@jakevdp alt.renderers.set_embed_options(actions=False) works well in Notebook. However when I do the same in a script it doesn't seem to work. In my script I actually return to_json() called on the chart by a function which is then embedded using vega embed.
Is there any way to make it work there? I tried looking for passing kwargs = {'actions': False} in to_json but that gives errors.
@jakevdp I found a way...was experimenting with it and the important piece is {"actions": false, "mode": "vega-lite"}
So if using templates it can be used as -
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/vega@{vega_version}"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@{vegalite_version}"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@{vegaembed_version}"></script>
</head>
<body>
<div id="vis1"></div>
<script type="text/javascript">
vegaEmbed('#vis1', {spec1}, {kwargs}).catch(console.error);
</script>
</body>
</html>
"""
with open('viz.html', 'w') as f:
f.write(two_charts_template.format(
vega_version=alt.VEGA_VERSION,
vegalite_version=alt.VEGALITE_VERSION,
vegaembed_version=alt.VEGAEMBED_VERSION,
spec1=final_map.to_json(indent=None),
kwargs = """{"actions": false, "mode": "vega-lite"}"""
# spec2=final_map.to_json(indent=None),
))
We should document this somewhere too
It鈥檚 documented in the Vega-Embed docs. Since you鈥檙e using Vega-Embed to display your exported JSON, that seems like the appropriate place.
Most helpful comment
The
save()method accepts anembed_optionsparameter, that lets you specify this sort of thing. So, for example you could do