Skip to content
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

Customizing the actions links in the Altair charts #2302

Closed
sgsfak opened this issue Sep 12, 2024 · 1 comment · Fixed by #2303
Closed

Customizing the actions links in the Altair charts #2302

sgsfak opened this issue Sep 12, 2024 · 1 comment · Fixed by #2303
Labels
bug Something isn't working

Comments

@sgsfak
Copy link

sgsfak commented Sep 12, 2024

Describe the bug

It seems that disabling the actions links in the Altair charts using altair.renderers.set_embed_options(actions=False) does not work. I am not sure whether it's marimo's or altair's issue. It's probably the latter since the same problem has been reported for streamlit.

The workaround proposed in the Streamlit's discussion here is to do the following per chart:

chart["usermeta"] = {
    "embedOptions": {
        "actions": False,
    }
}

Environment

{
  "marimo": "0.8.13",
  "OS": "Darwin",
  "OS Version": "23.6.0",
  "Processor": "i386",
  "Python Version": "3.12.2",
  "Binaries": {
    "Browser": "128.0.6613.121",
    "Node": "v18.17.0"
  },
  "Dependencies": {
    "click": "8.1.7",
    "importlib-resources": "missing",
    "jedi": "0.19.1",
    "markdown": "3.7",
    "pygments": "2.18.0",
    "pymdown-extensions": "10.9",
    "ruff": "0.6.4",
    "starlette": "0.38.5",
    "tomlkit": "0.13.2",
    "typing-extensions": "4.12.2",
    "uvicorn": "0.30.6",
    "websockets": "12.0"
  },
  "Optional Dependencies": {
    "altair": "5.4.1",
    "duckdb": "1.0.0",
    "pandas": "2.2.2",
    "pyarrow": "17.0.0"
  }
}

Code to reproduce

import marimo as mo
import pandas as pd
import altair as alt

alt.renderers.set_embed_options(actions=False)

df = pd.DataFrame({"x": [1,2,3], "y": [10,20,30]})

chart = alt.Chart(df).mark_point().encode(x="x", y="y")
mo.ui.altair_chart(chart)

## However, using the following per chart works:

chart["usermeta"] = {
   "embedOptions": {
       "actions": False,
    }
}

mo.ui.altair_chart(chart)
@mscolnick
Copy link
Contributor

Thanks for the detailed issue. I am surprised that altair does not handle this internally, but using your workaround, I can make this embedOptions set globally are always set on all charts.

PR here: #2303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants