Summary
I am trying for my app to have a callback for the click event in a plotly chart setup by streamlit. I want for the graph to not reset once the click action is performed on the chart and maintain the axis in their old positions.
Steps to reproduce
Code snippet:
import streamlit as st
from streamlit_plotly_events import plotly_events
import plotly.express as px
import pandas as pd
df = pd.DataFrame(dict(
x = [1, 3, 2, 4],
y = [1, 2, 3, 4]
))
fig = px.line(df, x="x", y="y", title="Unsorted Input", markers=True)
selected_points = plotly_events(fig, key="test")
st.write(selected_points)
This is a small reproducible example. The following libs are required:
- streamlit
- pandas
- plotly
- streamlit_plotly_events
Run this code using streamlit run main.py
and then try and zoom into the chart so only one point is visible. Click on any of the (x, y)
points from the chart. The chart resets to the old position (the equivalent of clicking on the reset axis button).
Expected behavior:
Load another streamlit component like a table when the point is clicked and maintain the plot in the zoomed-in position.
Actual behavior:
The graph resets to the default position and the zoomed in position is lost.
Debug info
- Streamlit version: 1.15.0
- Python version: 3.7
- Using Conda? PipEnv? PyEnv? Pex?
- OS version: macos Ventura
- Browser version: Chrome/Safari