Skip to content
Advertisement

Is there a way to combine a loading data callback and a recurrent updating data callback with dash-python?

I am working on a dashboard with dash-plotly and I have created two different callbacks to handle data storage. The first callback loads initial data based on a dropdown

JavaScript

While the second gets as input the initial data and then updates it recurrently

JavaScript

However, in this way, it doesn’t work because I use the same ID for two different callbacks. Do you know if there is a way to make it work? Or if you know a strategy to address this? Initially, I would like to load only the data from a single battery to avoid crashing the dashboard and then I need to get the data updated every 10 secs.

Thanks for any suggestion or help!

Advertisement

Answer

You can fix this issue by using the great dash-extensions library.

This library has some modules that modify the Dash and allow us to extend it to do more than the standard Plotly does. By using a module called MultiplexerTransform combined with DashProxy you will be able to use the same ID in different callback outputs;

Below is a code snippet which does exactly what you did, you just need to adjust it to your context.

JavaScript

To read more about this module and library you can read: dash-extensions

Regards,
Leonardo

Advertisement