Created
October 25, 2019 04:45
-
-
Save monchier/4ba216cc9168a7d2bea7f3f31a1c4491 to your computer and use it in GitHub Desktop.
dashboard.py
This file contains 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 | |
# session_state from https://gist.github.com/tvst/036da038ab3e999a64497f42de966a92 | |
from session_state import get | |
# st_rerun from https://gist.github.com/tvst/ef477845ac86962fa4c92ec6a72bb5bd | |
from st_rerun import rerun | |
session_state = get(values=[]) | |
if len(session_state.values) == 0: | |
session_state.values.append(0) | |
st.line_chart(session_state.values[-100:]) | |
new_value = session_state.values[-1] + random.randrange(-100, 100) / 100 | |
session_state.values.append(new_value) | |
time.sleep(.2) | |
rerun() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@palmarytech @monchier 's example is now supported natively in newer streamlit versions.
This script is working fine with
Streamlit, version 1.6.0