Line_charts are slow, even with low amount of data points

I’m reading data from sensors, which I understand might not be the best use case for Streamlit. Nonetheless, I like all the other features so much that I am willing to use Streamlit.

I’m wondering if there’s a way to speed up how fast line_charts take.

Here is an example:

import time
import random
import streamlit as st

data1 = deque([0]*5)
data2 = deque([0]*5)
graph1 = st.empty()
graph2 = st.empty()

while True:
    data1.append(5 + random.randint(-5, 5))
    data2.append(4 + random.randint(3, 9))

I expect the two graphs to update at around the same time every second, but instead the first one updates, a brief half second pause, and then the second one updates, and then there’s the 1 second delay. I don’t believe it’s because of the various deque operations as there is only 5 elements in these lists.

Also, because this is simulating sensor data, data is random and caching will be pretty much impossible.

Hi @kevinlinxc -

I suspect the issue you are running into is the Streamlit processing model, not that line_charts themselves are particularly slow. There’s another thread going on right now about trying to display data with high frame rates, perhaps you could modify that approach: