Is there a way to auto refresh the chart?The data is from some realtimeDB,like mysql or redis?
Hey @po_hi , Welcome to the forum!
There is an existing streamlit function that you can use in order to mutate and add new rows to a current rendered graph which is add_rows()
Is this what you were looking for?
I write a simple app in st. But the data is not refreshed everytime ,It is funny…
import streamlit as st
import numpy as np
a = 1
if st.button(“Say hello”):
a = a + 1
print(“in the print” + str(a))
st.write(“Why hello there” + str(a))
thanks a lot for posting to the forum.
st.button will return true
If the button was clicked on the last run of the app.
(From our doc)
On top of this pressing the button will trigger a re-run. Does this explain the behavior you are seeing with the code snipped you posted? Feel free to post a feature request here
As for auto-refreshing a chart, if you want to poll periodically a data source, you need programmatic re-runs. We are developing this feature and it is tracked here: https://github.com/streamlit/streamlit/issues/168. You will also need Session State to persist data across re-runs. We are also working on Session State. This topic has a more thorough discussion on it.
This gist, for example, uses programmatic reruns along with Session State to implement a dashboard. You can just try it out by downloading the Session State and reruns gists linked in the gist above.