Last active
September 12, 2021 13:46
-
-
Save andfanilo/a41ab075dfe79208235477dd4f750100 to your computer and use it in GitHub Desktop.
Example animated ECharts (more on https://discuss.streamlit.io/t/streamlit-echarts/3655/30)
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
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