admin管理员组文章数量:1296469
I have this use case where I have a plotlychart :
import streamlit as st
import plotly.express as px
if "var" not in st.session_state:
st.session_state["var"] = 0
col3,col4 = st.columns(2)
def plot():
df = px.data.iris()
fig = px.scatter(
df,
x="sepal_width",
y="sepal_length",
color="species",
size="petal_length",
hover_data=["petal_width"],
)
event = st.plotly_chart(fig, key="iris", on_select="rerun")
event.selection
if len(event.selection.points)!=0:
st.session_state["var"] = event.selection.points[0]["x"]
# st.rerun()
with col3:
st.write(st.session_state["var"])
with col4:
plot()
my issue is when I select a point on the graph, logically the st.session_state["var"] should be updated directly …but it is not the case here…I have tried to use st.rerun() but it is enter in infinity loop…do you have any idea please to make st.session_state["var"] updated directly when I select a point ? I want to keep the order of cols as it is. thanks
本文标签: pythonHow to make streamlit sessionstate updated when I select a point on plotlychartStack Overflow
版权声明:本文标题:python - How to make streamlit session_state updated when I select a point on plotly_chart - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741601081a2387704.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论