Created
December 12, 2022 22:18
-
-
Save Merwanski/9c14f5a10138a7c20843477d2fb6db1d to your computer and use it in GitHub Desktop.
simple_sliding_window_streamlit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Simple sliding window dashboard-style | |
plot that updates periodically pulling from | |
a random generator | |
""" | |
import streamlit as st | |
import time | |
import random | |
# values cannot be used in st.session_state!! | |
if 'my_values' not in st.session_state: | |
st.session_state.my_values = list() | |
if not st.session_state.my_values: | |
st.session_state.my_values.append(0) | |
st.line_chart(st.session_state.my_values[-100:]) | |
new_value = st.session_state.my_values[-1] + random.randrange(-100, 100) / 100 | |
st.session_state.my_values.append(new_value) | |
time.sleep(.2) | |
st.experimental_rerun() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment