Skip to content

Commit bd16d77

Browse files
author
Jon M. Mease
committed
Don't skip apply relayout/restyle/update operations on view that emitted event
This was a premature optimization that seems to lead to inconsistent states when there is only a single active view
1 parent 53ee212 commit bd16d77

File tree

1 file changed

+14
-52
lines changed

1 file changed

+14
-52
lines changed

Diff for: js/src/Figure.js

+14-52
Original file line numberDiff line numberDiff line change
@@ -1203,14 +1203,6 @@ var FigureView = widgets.DOMWidgetView.extend({
12031203
var traceIndexes = this.model._normalize_trace_indexes(
12041204
msgData.restyle_traces);
12051205

1206-
if (msgData.source_view_id === this.viewID) {
1207-
// Operation originated from this view, don't re-apply it
1208-
console.log("Skipping restyle for view " + this.viewID);
1209-
return
1210-
} else {
1211-
console.log("Applying restyle for view " + this.viewID)
1212-
}
1213-
12141206
restyleData["_doNotReportToPy"] = true;
12151207
Plotly.restyle(this.el, restyleData, traceIndexes);
12161208

@@ -1235,16 +1227,9 @@ var FigureView = widgets.DOMWidgetView.extend({
12351227
var msgData = this.model.get("_py2js_relayout");
12361228
if (msgData !== null) {
12371229

1238-
if (msgData.source_view_id === this.viewID) {
1239-
// Operation originated from this view, don't re-apply it
1240-
console.log("Skipping relayout for view " + this.viewID);
1241-
} else {
1242-
console.log("Applying relayout for view " + this.viewID);
1243-
1244-
var relayoutData = msgData.relayout_data;
1230+
var relayoutData = msgData.relayout_data;
12451231
relayoutData["_doNotReportToPy"] = true;
12461232
Plotly.relayout(this.el, msgData.relayout_data);
1247-
}
12481233

12491234
// ### Send layout delta ###
12501235
var layout_edit_id = msgData.layout_edit_id;
@@ -1267,15 +1252,8 @@ var FigureView = widgets.DOMWidgetView.extend({
12671252
var traceIndexes = this.model._normalize_trace_indexes(
12681253
msgData.style_traces);
12691254

1270-
if (msgData.source_view_id === this.viewID) {
1271-
// Operation originated from this view, don't re-apply it
1272-
console.log("Skipping update for view " + this.viewID);
1273-
} else {
1274-
console.log("Applying update for view " + this.viewID)
1275-
1276-
style["_doNotReportToPy"] = true;
1255+
style["_doNotReportToPy"] = true;
12771256
Plotly.update(this.el, style, layout, traceIndexes);
1278-
}
12791257

12801258
// ### Send trace deltas ###
12811259
// We create an array of deltas corresponding to the updated
@@ -1314,38 +1292,22 @@ var FigureView = widgets.DOMWidgetView.extend({
13141292
traces: traceIndexes
13151293
};
13161294

1317-
if (msgData.source_view_id === this.viewID) {
1318-
// Operation originated from this view, don't re-apply it
1319-
console.log("Skipping animate for view " + this.viewID);
1320-
1321-
// ### Send trace deltas ###
1322-
// We create an array of deltas corresponding to the
1323-
// animated traces.
1324-
this._sendTraceDeltas(msgData.trace_edit_id);
1325-
1326-
// ### Send layout delta ###
1327-
var layout_edit_id = msgData.layout_edit_id;
1328-
this._sendLayoutDelta(layout_edit_id);
1329-
1330-
} else {
1331-
console.log("Applying animate for view " + this.viewID)
1295+
animationData["_doNotReportToPy"] = true;
1296+
var that = this;
13321297

1333-
animationData["_doNotReportToPy"] = true;
1334-
var that = this;
1298+
Plotly.animate(this.el, animationData, animationOpts).then(
1299+
function () {
13351300

1336-
Plotly.animate(this.el, animationData, animationOpts).then(
1337-
function () {
1301+
// ### Send trace deltas ###
1302+
// We create an array of deltas corresponding to the
1303+
// animated traces.
1304+
that._sendTraceDeltas(msgData.trace_edit_id);
13381305

1339-
// ### Send trace deltas ###
1340-
// We create an array of deltas corresponding to the
1341-
// animated traces.
1342-
that._sendTraceDeltas(msgData.trace_edit_id);
1306+
// ### Send layout delta ###
1307+
var layout_edit_id = msgData.layout_edit_id;
1308+
that._sendLayoutDelta(layout_edit_id);
1309+
});
13431310

1344-
// ### Send layout delta ###
1345-
var layout_edit_id = msgData.layout_edit_id;
1346-
that._sendLayoutDelta(layout_edit_id);
1347-
});
1348-
}
13491311
}
13501312
},
13511313

0 commit comments

Comments
 (0)