plotly / dash-core-components

OBSOLETE: now part of https://github.com/plotly/dash
https://dash.plotly.com
MIT License
270 stars 147 forks source link

dcc Graphs reset their relayout on tab change #1007

Open matt-sd-watson opened 1 year ago

matt-sd-watson commented 1 year ago

I have a few dcc.Graphs that render histograms in my Dash app. In one instance, I have a callback that will update a shape on the histogram if the proper data exists in dcc.Loading.

Upon updating the callback, the relayout of the graph will look something like this:

{'shapes': [{'editable': True, 'label': {'text': ''}, 'xref': 'x', 'yref': 'y', 'layer': 'above', 'opacity': 1, 'line': {'color': '#444', 'width': 4, 'dash': 'solid'}, 'fillcolor': 'rgba(0,0,0,0)', 'fillrule': 'evenodd', 'type': 'rect', 'x0': 10.060903897849462, 'y0': 44456.17081925675, 'x1': 23.7705813172043, 'y1': -804.9102618243243}]}

however, on a tab change within the app, upon returning to the tab with the histogram, the relayout of the histogram has updated to:

{'autosize': True}

despite having no logic within the callbacks to allow a callback on a tab change. This continues to occur even by limiting callbacks to no include certain actions such as:

ctx.triggered_id != "tabs"

where tabs is the id of the tab set.

This is odd because the shape that is declared in the callback is not removed or modified in any way, but the change to the relayout affects a number of other linked callbacks erroneously.