marimo icon indicating copy to clipboard operation
marimo copied to clipboard

Tooltips for altair charts do not work in fullscreen mode

Open mokhin opened this issue 7 months ago • 1 comments

Describe the bug

When you switch to full-screen mode for altair charts, the tooltips stop working.

Environment

{
  "marimo": "0.13.0",
  "OS": "Darwin",
  "OS Version": "24.1.0",
  "Processor": "arm",
  "Python Version": "3.12.9",
  "Binaries": {
    "Browser": "135.0.7049.96",
    "Node": "v23.11.0"
  },
  "Dependencies": {
    "click": "8.1.8",
    "docutils": "0.21.2",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.8",
    "narwhals": "1.35.0",
    "packaging": "24.2",
    "psutil": "7.0.0",
    "pygments": "2.19.1",
    "pymdown-extensions": "10.14.3",
    "pyyaml": "6.0.2",
    "ruff": "0.11.5",
    "starlette": "0.46.2",
    "tomlkit": "0.13.2",
    "typing-extensions": "4.13.2",
    "uvicorn": "0.34.1",
    "websockets": "15.0.1"
  },
  "Optional Dependencies": {},
  "Experimental Flags": {
    "lsp": true,
    "table_charts": false,
    "inline_ai_tooltip": false
  }
}

Code to reproduce

# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "altair==5.5.0",
#     "marimo==0.13.0",
#     "pyarrow==19.0.1",
#     "vega-datasets==0.9.0",
#     "vegafusion==2.0.2",
#     "vl-convert-python==1.7.0",
# ]
# ///

import marimo

__generated_with = "0.13.0"
app = marimo.App(width="medium")


@app.cell
def _():
    import marimo as mo
    import altair as alt
    import vega_datasets
    return alt, mo, vega_datasets


@app.cell
def _(alt, mo, vega_datasets):
    # Load some data
    cars = vega_datasets.data.cars()

    # Create an Altair chart
    chart = alt.Chart(cars).mark_point().encode(
        x='Horsepower', # Encoding along the x-axis
        y='Miles_per_Gallon', # Encoding along the y-axis
        color='Origin', # Category encoding by color
    )

    # Make it reactive ⚡
    chart = mo.ui.altair_chart(chart)
    return (chart,)


@app.cell
def _(chart, mo):
    mo.vstack([chart, chart.value.head()])
    return


if __name__ == "__main__":
    app.run()

mokhin avatar Apr 23 '25 18:04 mokhin

hey @mokhin, can you file this issue on https://github.com/vega/vega-tooltip/, it looks like it should be handled there.

They had an issue previously and added a fix, but looking at the code, it doesn't seem to handle when the view changes to fullscreen.

mscolnick avatar Apr 23 '25 19:04 mscolnick

Interestingly, if you select Open in Vega Editor where it renders with Vega-lite, then the fullscreen mode there works fine, the tooltips are ok. Is it perhaps fixed in Vega but not pulled through yet into altair?

matthalstead avatar Aug 01 '25 03:08 matthalstead

@matthalstead it is because we render ours in a ShadowDom, however the Vega playground does not

mscolnick avatar Aug 01 '25 03:08 mscolnick