-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
When adding a selection interval to an altair plot, the selection rectangle has a tooltip "true". There should not be a tooltip for the selection mark.
Reproducible Code Example
import altair as alt
import streamlit as st
from vega_datasets import data
# Load data
cars = data.cars()
# Selection parameter
selection = alt.selection_interval()
# Create scatter plot
scatter_plot = (
alt.Chart(cars)
.mark_circle()
.encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
tooltip=['Name', 'Horsepower', 'Miles_per_Gallon']
)
.add_params(selection)
.properties(title='Horsepower vs. Miles per Gallon')
)
st.altair_chart(scatter_plot)Steps To Reproduce
- Click and drag to create selection rectangle
- Hover over the selection rectangle
Expected Behavior
The drag cursor shows (and there is no tooltip).
Current Behavior
The drag cursor shows along with the tooltip "true".
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.42.1
- Python version: 3.12
- Operating System: MacOS
- Browser: Chrome
Additional Information
I see that the streamlit vega-lite theme enables tooltips by default. I was looking at vega/vega-lite#6522 which lead me to tinker with the vega-lite config. I think all is needed is to update
streamlit/frontend/lib/src/components/elements/ArrowVegaLiteChart/CustomTheme.tsx
Line 124 in 596657b
| tooltip: true, |
to
tooltip: {content: "encoding"}I can reproduce the behavior in the vega editor.
See example I with config {"mark": {"tooltip": {"content": "encoding"}}} vs. example II with config {"mark": {"tooltip": true}}.
Example II has the "true" tooltip, while example I works as expected.
