ajander / bird-behavior

0 stars 0 forks source link

Set up Streamlit app to display streaming data #7

Open ajander opened 1 year ago

ajander commented 1 year ago

See if I can create a live updating graph - even though I might not have high enough frequency data to actually need this for the Bird Behavior app.

ajander commented 1 year ago

Learned a new data structure, collections.deque (double-ended queue). You can use it to implement a queue (FIFO) or a stack (LIFO). This is a nice way to keep just the data points I currently want to show.

Used deques in session state variables to hold the data of interest (x and y).

Used placeholder containers to allocate space for the graph but continue execution to fill the rest of the page with unrelated stuff (i.e., the live graph doesn't block the rest of the code from executing).

Streamlit is not really designed for this kind of thing, with its consecutive script-like execution. It doesn't do callbacks and it seems tough to do anything async. I may have to eventually move to something a little more advanced.