Skip to content
Advertisement

How do I implement Dash/Plotly checklist persistence on a layout with multiple unique graphs?

My dashboard has a 2 x 2 graph layout with one checklist overlaid on each graph.

Enter image description here

Each graph requires a unique ID, to be live-updated via callbacks. These IDs are generated in a loop (e.g., graph-BMW, graph-MB, etc.). Similarly, each checklist has a unique ID generated via the same loop (e.g., checklist-BMW, checklist-MB, etc.). These IDs are passed to the input and output of the callback.

Graph data is calculated and the checklist value and figure are returned.

Since the checklist needs to be contained in the same DIV as the graph, they are nested and then unpacked in the layout.

All of this works perfectly, with one exception: persistence doesn’t work. If a checklist is clicked, I’m unable to retain the current (new) state when refreshing the page. The checklist value always returns to unchecked, as it seems to be reset.

How can I resolve this?

A stripped-down version of the application:

JavaScript

Advertisement

Answer

It seems that the circular callback breaks the persistence functionality. Removing it by dropping the checklist output, persistence works as intended. Here is an MWE,

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement