eaglelandsonce commited on
Commit
8fc1a61
·
verified ·
1 Parent(s): 5cfb870

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -1,27 +1,30 @@
1
- import time
2
- import requests
3
-
4
  import streamlit as st
5
- from streamlit_lottie import st_lottie
6
- from streamlit_lottie import st_lottie_spinner
7
-
 
 
8
 
9
- def load_lottieurl(url: str):
10
- r = requests.get(url)
11
- if r.status_code != 200:
12
- return None
13
- return r.json()
14
 
 
 
15
 
16
- lottie_url_hello = "https://assets5.lottiefiles.com/packages/lf20_V9t630.json"
17
- lottie_url_download = "https://assets4.lottiefiles.com/private_files/lf30_t26law.json"
18
- lottie_hello = load_lottieurl(lottie_url_hello)
19
- lottie_download = load_lottieurl(lottie_url_download)
 
 
20
 
 
 
 
21
 
22
- st_lottie(lottie_hello, key="hello")
 
23
 
24
- if st.button("Download"):
25
- with st_lottie_spinner(lottie_download, key="download"):
26
- time.sleep(5)
27
- st.balloons()
 
 
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ import plotly.express as px
4
+ from itertools import count
5
+ import random
6
+ import time
7
 
8
+ # Initialize count for x-axis and empty DataFrame for storing data
9
+ index = count()
10
+ data = pd.DataFrame(columns=['x', 'y'])
 
 
11
 
12
+ # Placeholder for the Plotly chart
13
+ chart_placeholder = st.empty()
14
 
15
+ while True: # This loop will simulate real-time data updates
16
+ # Append new data point
17
+ new_x = next(index)
18
+ new_y = random.randint(0, 5)
19
+ new_data = pd.DataFrame({'x': [new_x], 'y': [new_y]})
20
+ data = pd.concat([data, new_data], ignore_index=True)
21
 
22
+ # Create a new Plotly figure
23
+ fig = px.line(data, x='x', y='y', title="Real-time Data Plot")
24
+ fig.update_layout(xaxis_title='X Axis', yaxis_title='Y Axis', autosize=True)
25
 
26
+ # Display the figure using Streamlit
27
+ chart_placeholder.plotly_chart(fig, use_container_width=True)
28
 
29
+ # Pause for a moment before updating the chart with new data
30
+ time.sleep(1)