From 18b51c2c2887e6c6b313be765ed94f03ca68aaee Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Fri, 19 Jul 2019 19:55:17 -0400 Subject: [PATCH 1/2] Send the moveTraces message after the figure's data has been updated. This way, subclasses have access to the new figure state. --- packages/python/plotly/plotly/basedatatypes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/python/plotly/plotly/basedatatypes.py b/packages/python/plotly/plotly/basedatatypes.py index 0639dc68050..d83d529ba71 100644 --- a/packages/python/plotly/plotly/basedatatypes.py +++ b/packages/python/plotly/plotly/basedatatypes.py @@ -642,9 +642,6 @@ def data(self, new_data): # ### Check whether a move is needed ### if not all([i1 == i2 for i1, i2 in zip(new_inds, current_inds)]): - # #### Update widget, if any #### - self._send_moveTraces_msg(current_inds, new_inds) - # #### Reorder trace elements #### # We do so in-place so we don't trigger traitlet property # serialization for the FigureWidget case @@ -664,6 +661,9 @@ def data(self, new_data): for ni, trace_data in zip(new_inds, moving_traces_data): self._data.insert(ni, trace_data) + # #### Update widget, if any #### + self._send_moveTraces_msg(current_inds, new_inds) + # ### Update data defaults ### # There is to front-end syncronization to worry about so this # operations doesn't need to be in-place From bc48a18f73f17751080adc9927fef2c34872340d Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Sat, 20 Jul 2019 05:21:44 -0400 Subject: [PATCH 2/2] Fix contents of moveTraces message --- packages/python/plotly/plotly/basedatatypes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/basedatatypes.py b/packages/python/plotly/plotly/basedatatypes.py index d83d529ba71..a423ae11978 100644 --- a/packages/python/plotly/plotly/basedatatypes.py +++ b/packages/python/plotly/plotly/basedatatypes.py @@ -642,6 +642,10 @@ def data(self, new_data): # ### Check whether a move is needed ### if not all([i1 == i2 for i1, i2 in zip(new_inds, current_inds)]): + # #### Save off index lists for moveTraces message #### + msg_current_inds = current_inds + msg_new_inds = new_inds + # #### Reorder trace elements #### # We do so in-place so we don't trigger traitlet property # serialization for the FigureWidget case @@ -662,7 +666,7 @@ def data(self, new_data): self._data.insert(ni, trace_data) # #### Update widget, if any #### - self._send_moveTraces_msg(current_inds, new_inds) + self._send_moveTraces_msg(msg_current_inds, msg_new_inds) # ### Update data defaults ### # There is to front-end syncronization to worry about so this