Summary
I have developed an app to plot the values in a altair chart. The values are first appended in the pandas dataframe and then plotted using the altair chart. The app works fine in the single user case. In the multi user case, app throws the Unrecognised dataset error in the plotting area.
Steps to reproduce
Import the necessary libraries
Declare the pandas dataframe
Declare the data to be plotted
Append the data one by one in the dataframe
Plot the data using altair chart
Code snippet:
import streamlit as st
import pandas as pd
from datetime import datetime, timedelta
import altair as alt
import time as t
import math
st.title("Sine wave Plotting")
df_Tidal_Volume = pd.DataFrame(columns=["time","Tidal_Volume"])
chart_Tidal_Volume = st.empty()
start_time = datetime.now()
while True:
try:
data = [5*math.sin(math.radians(0)),5*math.sin(math.radians(9)),5*math.sin(math.radians(13.5)),5*math.sin(math.radians(18)),5*math.sin(math.radians(22.5)),5*math.sin(math.radians(27)),5*math.sin(math.radians(31.5)),5*math.sin(math.radians(36)),5*math.sin(math.radians(40.5)),5*math.sin(math.radians(45))]
t.sleep(0.03)
time = datetime.now()
df_Tidal_Volume = df_Tidal_Volume.append({"time": time, "Tidal_Volume": data[0]}, ignore_index=True)
latest_time = time - start_time
if latest_time >= timedelta(milliseconds=50):
a=chart_Tidal_Volume.altair_chart(alt.Chart(df_Tidal_Volume.tail(200)).mark_line().encode(x='time',y=alt.Y('Tidal_Volume', scale=alt.Scale(domain=[0,6]))))
print("Plot Success")
else:
print("Data not received")
t.sleep(0.03)
Append more data from the given array and plot using altair chart. Deploy the app. While accessing the app by more than one user at a time, the error occurs.
Expected behavior:
The app should plot the data while accessing the app from multiple devices
Actual behavior:
The app throws the following error while accessing from more than one device
Links
- Link to your GitHub repo:appdevelopment/st1.py at main · santhosh-graceson/appdevelopment · GitHub
- Link to your deployed app:https://abcd1234.streamlit.app/