-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document set_embed_options
#2672
Comments
For the record, the function itself https://github.com/altair-viz/altair/blob/3e60c99f1ee2b80461a40412e1e0a9689da82f1a/altair/utils/display.py#L39 is documented, but it's just not part of the web docs, likely because the Though I will say that additional info could be useful. For example, it looks like setting >>> import altair as alt
>>> import pandas as pd
>>> df = pd.DataFrame({"x": [1, 2, 3, 4], "y": [1, 2, 3, 4], "name": ["A", "B", "C", "D"]})
>>> chart_wo_embed_opts = alt.Chart(df).mark_circle().encode(x="x:O", y="y:O")
>>> alt.renderers.set_embed_options(actions=False)
RendererRegistry.enable('default')
>>> chart_with_embed_opts = alt.Chart(df).mark_circle().encode(x="x:O", y="y:O")
>>> chart_wo_embed_opts.to_json() == chart_with_embed_opts.to_json()
True Not sure if this is intended or not. If not, I'll open a separate Issue. |
embed options do not affect the chart specification, they control the HTML and Javascript code used to display the chart specification in the frontend. That's why we need a weird global config rather than using a chart method that modifies the chart object. |
You can check the effect like this, for example: >>> import altair as alt
>>> import pandas as pd
>>> df = pd.DataFrame({"x": [1, 2, 3, 4], "y": [1, 2, 3, 4], "name": ["A", "B", "C", "D"]})
>>> chart = alt.Chart(df).mark_circle().encode(x="x:O", y="y:O")
>>> alt.renderers.set_embed_options(actions=False)
>>> html = chart._repr_mimebundle_()['text/html'] # _repr_mimebundle_ is what JupyterLab uses for rich display
>>> print('"actions": false' in html)
True
>>> print('"actions": true' in html)
False
>>> alt.renderers.set_embed_options(actions=True)
>>> html = chart._repr_mimebundle_()['text/html']
>>> print('"actions": false' in html)
False
>>> print('"actions": true' in html)
True |
Thanks for the info - I figured it was intentional but I wanted to confirm. Searching for |
As per https://stackoverflow.com/questions/73476232/altair-disable-the-open-in-vega-editor-option-in-a-colab-jupyter-notebook I only see a mention in the changelog https://altair-viz.github.io/search.html?q=set_embed_options&check_keywords=yes&area=default
The text was updated successfully, but these errors were encountered: