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() |
@palmarytech @monchier 's example is now supported natively in newer streamlit versions.
"""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()
This script is working fine with Streamlit, version 1.6.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, monchier
run this code i met the error as below
could you give me some advice, Thanks