✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

How to refresh data on fly?

With Dash, I can create an interactive dashboard.

But, in most Dash apps, the data is used by a CSV file.

I want to use MySQL data, which keeps growing with time.

But I met a problem, hot to make data refresh on fly?

At the start of Dash, I need to read data from MySQL, and form it into dataframe, which used by figured.
Once the Dash app is started, the data can not be updated, unless by restart the app.

Is there any ways to refresh the data?

Option 1 - Make app.layout a function (https://dash.plot.ly/live-updates) and set the data on page load and pass it through to different callbacks with hidden divs: https://dash.plot.ly/sharing-data-between-callbacks
Option 2 - Run a separate scheduling process that updates the data periodically and stores the data in Redis: https://github.com/plotly/dash-redis-celery-periodic-updates/.

A post was split to a new topic: MS SQL and Dash

In the live-updates example, the entire plot is redrawn on every interval tick. This clears any interactions the user has had with the plot such as zooming. How can we update the data while retaining view modifications made by the user?

See uirevision: 📣 Preserving UI State, like Zoom, in dcc.Graph with uirevision with Dash

1 Like