Skip to content

Commit 53ee212

Browse files
author
Jon M. Mease
committed
Dispaatch changes to callbacks after sending udpate messages to the
frontend. Resolves inconsistency when callbacks trigger frontend calls as well
1 parent b74ff02 commit 53ee212

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

Diff for: plotly/basedatatypes.py

+28-26
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,14 @@ def plotly_restyle(self, restyle_data, trace_indexes=None, **kwargs):
491491
# The restyle operation resulted in a change to some trace
492492
# properties, so we dispatch change callbacks and send the
493493
# restyle message to the frontend (if any)
494-
self._dispatch_trace_change_callbacks(
495-
restyle_changes, trace_indexes)
496494
self._send_restyle_msg(
497495
restyle_changes,
498496
trace_indexes=trace_indexes,
499497
source_view_id=source_view_id)
500498

499+
self._dispatch_trace_change_callbacks(
500+
restyle_changes, trace_indexes)
501+
501502
return self
502503

503504
def _perform_plotly_restyle(self, restyle_data, trace_indexes):
@@ -587,8 +588,8 @@ def _restyle_child(self, child, key_path_str, val):
587588
if not self._in_batch_mode:
588589
send_val = [val]
589590
restyle = {key_path_str: send_val}
590-
self._dispatch_trace_change_callbacks(restyle, [trace_index])
591591
self._send_restyle_msg(restyle, trace_indexes=trace_index)
592+
self._dispatch_trace_change_callbacks(restyle, [trace_index])
592593

593594
# In batch mode
594595
# -------------
@@ -1105,11 +1106,12 @@ def plotly_relayout(self, relayout_data, **kwargs):
11051106
# The relayout operation resulted in a change to some layout
11061107
# properties, so we dispatch change callbacks and send the
11071108
# relayout message to the frontend (if any)
1108-
self._dispatch_layout_change_callbacks(relayout_changes)
11091109
self._send_relayout_msg(
11101110
relayout_changes,
11111111
source_view_id=source_view_id)
11121112

1113+
self._dispatch_layout_change_callbacks(relayout_changes)
1114+
11131115
return self
11141116

11151117
def _perform_plotly_relayout(self, relayout_data):
@@ -1173,8 +1175,8 @@ def _relayout_child(self, child, key_path_str, val):
11731175
# Dispatch change callbacks and send relayout message
11741176
if not self._in_batch_mode:
11751177
relayout_msg = {key_path_str: val}
1176-
self._dispatch_layout_change_callbacks(relayout_msg)
11771178
self._send_relayout_msg(relayout_msg)
1179+
self._dispatch_layout_change_callbacks(relayout_msg)
11781180

11791181
# In batch mode
11801182
# -------------
@@ -1376,6 +1378,16 @@ def plotly_update(self,
13761378
relayout_data=relayout_data,
13771379
trace_indexes=trace_indexes)
13781380

1381+
# Send update message
1382+
# -------------------
1383+
# Send a plotly_update message to the frontend (if any)
1384+
if restyle_changes or relayout_changes:
1385+
self._send_update_msg(
1386+
restyle_changes,
1387+
relayout_changes,
1388+
trace_indexes,
1389+
source_view_id=source_view_id)
1390+
13791391
# Dispatch changes
13801392
# ----------------
13811393
# ### Dispatch restyle changes ###
@@ -1387,16 +1399,6 @@ def plotly_update(self,
13871399
if relayout_changes:
13881400
self._dispatch_layout_change_callbacks(relayout_changes)
13891401

1390-
# Send update message
1391-
# -------------------
1392-
# Send a plotly_update message to the frontend (if any)
1393-
if restyle_changes or relayout_changes:
1394-
self._send_update_msg(
1395-
restyle_changes,
1396-
relayout_changes,
1397-
trace_indexes,
1398-
source_view_id=source_view_id)
1399-
14001402
return self
14011403

14021404
def _perform_plotly_update(self, restyle_data=None, relayout_data=None,
@@ -1696,17 +1698,6 @@ def _perform_batch_animate(self, animation_opts):
16961698
relayout_data,
16971699
trace_indexes)
16981700

1699-
# Dispatch callbacks
1700-
# ------------------
1701-
# ### Dispatch restyle changes ###
1702-
if restyle_changes:
1703-
self._dispatch_trace_change_callbacks(restyle_changes,
1704-
trace_indexes)
1705-
1706-
# ### Dispatch relayout changes ###
1707-
if relayout_changes:
1708-
self._dispatch_layout_change_callbacks(relayout_changes)
1709-
17101701
# Convert style / trace_indexes into animate form
17111702
# -----------------------------------------------
17121703
if self._batch_trace_edits:
@@ -1732,6 +1723,17 @@ def _perform_batch_animate(self, animation_opts):
17321723
self._batch_layout_edits.clear()
17331724
self._batch_trace_edits.clear()
17341725

1726+
# Dispatch callbacks
1727+
# ------------------
1728+
# ### Dispatch restyle changes ###
1729+
if restyle_changes:
1730+
self._dispatch_trace_change_callbacks(restyle_changes,
1731+
trace_indexes)
1732+
1733+
# ### Dispatch relayout changes ###
1734+
if relayout_changes:
1735+
self._dispatch_layout_change_callbacks(relayout_changes)
1736+
17351737
# Exports
17361738
# -------
17371739
def to_dict(self):

0 commit comments

Comments
 (0)