figure as state out of sync
See original GitHub issueIn this simple app from @emmanuelle, figure.layout.shapes doesn’t seem to be updated when figure is captured as State, meaning that we have to do all sorts of gymnastics with relayoutData to work with shapes.
@alexcjohnson can you help me figure out if this is something in dcc or if Plotly.js is doing something odd here, in which case help me translate this into a CodePen that @archmoj can use?
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objects as go
from dash.dependencies import Input, Output, State
import dash
import json
app = dash.Dash(__name__)
fig = go.Figure().update_layout(dragmode='drawrect')
app.layout = html.Div([
dcc.Graph(id='graph', figure=fig),
html.Pre(id='annotations-data'),
])
@app.callback(
Output('annotations-data', 'children'),
[Input("graph", "relayoutData")],
[State("graph", "figure")]
)
def on_new_annotation(relayout_data, fig):
return json.dumps(go.Figure(fig).layout.shapes, indent=2)
app.run_server(debug=True)
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Redux: Can't figure out why ownProps gets out of sync with state
Problem. In ConnectedList , state.listItems was not empty, so List renders an instance of ConnectedListItem . However, state.
Read more >Don't Sync State. Derive It! - Kent C. Dodds
Let's find out the benefits of derived state over state synchronization by reimplementing this with a more naive approach.
Read more >How to Fix Out of Sync Audio and Video in Windows 10
1. Try These Easy Solutions · 2. Run the Audio Troubleshooter · 3. Check Speaker Properties · 4 . Restore Default Settings for...
Read more >Out of sync Definition & Meaning - Merriam-Webster
in a state in which two or more people or things do not move or happen together at the same time and speed....
Read more >SyncChecker: Detecting Synchronization Errors between MPI ...
out corrupted message data or reading undefined message data. ... Figure 3 shows the state machine for detecting synchronization errors.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@almarklein, @nicolaskruchten mentioned that https://github.com/plotly/dash-core-components/issues/584 targets the same piece of the
dcccode so that it could be interesting to target the two issues together.I am running into related issues with a callback that Outputs a figure and loads the figure from a State. Many of deeper attributes, like line_colors of traces or _grid_ref are set to None in the figure dictionary received from State.
I had to use various hacks, like creating empty figures with subplot grids or storing color information in store objects and adding them back in annoying for-loops over the traces.
Is it somehow possible to return a “deep dictionary” of a figure that retains attributes currently lost?
I am using Dash 2.5.0.