Skip to content

Instantly share code, notes, and snippets.

@Merwanski
Created December 12, 2022 22:18
Show Gist options
  • Save Merwanski/9c14f5a10138a7c20843477d2fb6db1d to your computer and use it in GitHub Desktop.
Save Merwanski/9c14f5a10138a7c20843477d2fb6db1d to your computer and use it in GitHub Desktop.
simple_sliding_window_streamlit
"""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