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.popleft()
    data1.append(5 + random.randint(-5, 5))
    data2.popleft()
    data2.append(4 + random.randint(3, 9))
    graph1.line_chart(list(data1))
    graph2.line_chart(list(data2))
    time.sleep(1)

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:

Best,
Randy

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.