Black Lives Matter. Please consider donating to Black Girls Code today.

Load dynamic data?

I’m performing a school science experiment using a Raspberry Pi to capture temperature from four different sensors, once per minute. I’ve built a simple Dash site to plot my data using datetime as my ‘x’ and each of the four sensors are a unique line as ‘y’.

My plot/graph looks fantastic, however, it only works as a “one and done” point in time view. I would like to update the data at each page load.

As per the demos, I have attempted to make app.layout call a function which loads up my data into a pandas data frame, then builds my layout and returns it all at once. Unfortunately, the layout seems cached somehow/somewhere, and isn’t clear where that’s stored. If I stop/restart the server, it will load the new data, but not upon refreshing the page.

Any help would be appreciated.

See https://dash.plot.ly/live-updates

Thank you for the reply. I used the ‘Updates on Page Load’ method originally, which wasn’t working for me. Upon comparing your code, and my own, I discovered that if I drop the parenthesis from ‘app.layout = serve_layout()’ the page does indeed load my data file on refresh.

Thank you.