streamlit / streamlit

Streamlit — A faster way to build and share data apps.
https://streamlit.io
Apache License 2.0
35.59k stars 3.08k forks source link

Zoom/pan events for charts #8655

Open jrieke opened 5 months ago

jrieke commented 5 months ago

Checklist

Summary

We will soon add selections to charts (st.plotly_chart and st.altair_chart). At some point, we should also add a way to react to zoom/pan events on charts and return the bounding box of the displayed chart.

Why?

Let us know in the comments if you have specific use cases in mind!

How?

We should probably add a new event parameter (e.g. on_zoom_pan or on_relayout or on_move). Or we could think about integrating it with on_select in some way (which would make the implementation a lot easier but might be a bit less obvious from UX perspective).

Additional Context

Altair already supports this via selections events: using .interactive() in Altair adds a selection interval event (https://altair-viz.github.io/user_guide/interactions.html#scale-binding) and is a shortcut for alt.selection_interval(bind='scales'). You can use that to get the area the user is currently viewing.

github-actions[bot] commented 5 months ago

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Visits

m4rkus commented 5 months ago

I would love to see this implemented. I started using Streamlit yesterday and was looking for ways to connect events from Plotly charts to drive other components.

My use case involves segmenting and feature detection of flight data. Plotly is very convenient for plotting the various parameters needed for analysis. It would be extremely helpful to be able to zoom in on parts of the Plotly graphs and have a second Pydeck component automatically update to display the corresponding portion of the flight path. This would allow for easy cross-referencing between pydeck and plotly, which I currently cannot achieve.

Screenshot 2024-06-01 at 20 45 05