Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Vega-lite selection interval shows "true" tooltip #10448

@foldager

Description

@foldager

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.

Image

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

  1. Click and drag to create selection rectangle
  2. 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

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.

Example II:
Example II

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.altair_chartRelated to the `st.altair_chart` elementpriority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions