Skip to content

Instantly share code, notes, and snippets.

@andfanilo
Last active September 12, 2021 13:46
Show Gist options
  • Save andfanilo/a41ab075dfe79208235477dd4f750100 to your computer and use it in GitHub Desktop.
Save andfanilo/a41ab075dfe79208235477dd4f750100 to your computer and use it in GitHub Desktop.
import random
import time
import streamlit as st
from streamlit_echarts import st_echarts
MAX_ITERATIONS = 100
if "iteration" not in st.session_state:
st.session_state["iteration"] = 0
def download_data():
return [random.randint(0, 100) for _ in range(7)]
option = {
"xAxis": {
"type": "category",
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
},
"yAxis": {"type": "value", "max": 100},
"series": [
{
"data": download_data(),
"type": "bar",
"showBackground": True,
"backgroundStyle": {"color": "rgba(180, 180, 180, 0.2)"},
}
],
}
st.title("My realtime dashboard")
st_echarts(option, height="500px", key="chart")
time.sleep(1)
st.session_state["iteration"] += 1
if st.session_state["iteration"] < MAX_ITERATIONS:
st.experimental_rerun()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment