I have a dash board where users first define a main data frame and then apply some optional filters. The options of the filters depend on the loaded main data frame.
Once a user changes the main data frame, all the filters and resulting charts have to be updated. From what I understood, there multiple ways to achieve that:
For example, I could use the output of the first function which loads the main data frame in the other functions which create the filters and charts. Or I could chain callbacks and re-execute all other functions when the main data frame changes.
What is the recommended approach in my scenario and is there any documentation which shows pros and cons of each approach?
I would personally recommend using multiple outputs given your logic doesn’t get too complicated.
Chained callbacks have a noticeable user performance impact, but can be a more clean in terms of logical layout depending on your dashboards architecture.
Echoing Damian, use multiple outputs whenever possible due to the performance hit of chained callbacks.
However, I often use chained callbacks exactly like you describe because I have to do a lot of backend steps differently depending on the initial options or initial main data like in your example. The key is to let the user know that Don’t Worry, Something Is Happening while those things are running (if they are slow, that is) - otherwise it makes the app seem clunky and slow. I’d also love to see some documentation on this.
On a second thought and after looking through the examples:
Currently my source data frame is set globally as there is only one static file but now I need to change it to function scope as I am adding multiple options for the source df. I understand how to make it work with callbacks.
If I were to use the new multiple outputs feature, I have to put all the logic which creates the charts (currently in separate functions) into one single callback/function, correct?
I.e. it is not possible to output a variable which will then be used by multiple other functions, e.g. something like
Output('my_function, 'arg')
in combination with
def my_function(arg):