You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When passing a figure as a State variable in a callback, the data attribute of the figure seems to be modified. This results in it being difficult to access the x, y data from the figure and use it within the callback.
Expected behavior
Previously, the data attribute had the same structure as accessing the data attribute from the figure object itself which allowed for access to the data in the trace. The example below should make this explanation clearer.
The example is a simple Dash app which displays the data attribute of the figure directly from the figure object and after it is used as a State variable in the callback.
The output of fig["data"][0] is the trace as expected, however, accessing figure["data"][0] within the callback gives the following:
so the data is there but it's now quite difficult to get at.
For comparison, running dash 2.17.0, plotly 5.22.0 gives the required behaviour. Is this something that was changed in plotly v6? Is there now an easy way to access the data in a callback?
The text was updated successfully, but these errors were encountered:
gvwilson
changed the title
[BUG] Accessing figure as a State variable changes data attribute
Accessing figure as a State variable changes data attribute
Apr 8, 2025
Yeah this looks like a result of the typed array implementation. The intention is that the b64 encoded data is generally not surfaced directly to users so clearly there's a scenario we missed here -- thank you for the minimal example @bionictoucan !
Describe the bug
When passing a figure as a
State
variable in a callback, thedata
attribute of the figure seems to be modified. This results in it being difficult to access the x, y data from the figure and use it within the callback.Expected behavior
Previously, the
data
attribute had the same structure as accessing thedata
attribute from the figure object itself which allowed for access to the data in the trace. The example below should make this explanation clearer.Example
The example is a simple Dash app which displays the
data
attribute of the figure directly from the figure object and after it is used as aState
variable in the callback.The output of
fig["data"][0]
is the trace as expected, however, accessingfigure["data"][0]
within the callback gives the following:so the data is there but it's now quite difficult to get at.
For comparison, running dash 2.17.0, plotly 5.22.0 gives the required behaviour. Is this something that was changed in plotly v6? Is there now an easy way to access the data in a callback?
The text was updated successfully, but these errors were encountered: