From 58f9bb83103258d42fe8327bdc35f59e341bbe3c Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 13 Dec 2018 15:44:35 -0600 Subject: [PATCH] TraceManager should only delete traces that it has added itself --- inst/htmlwidgets/plotly.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/htmlwidgets/plotly.js b/inst/htmlwidgets/plotly.js index e693246f78..26ed2efac0 100644 --- a/inst/htmlwidgets/plotly.js +++ b/inst/htmlwidgets/plotly.js @@ -595,8 +595,8 @@ TraceManager.prototype.updateSelection = function(group, keys) { var nNewTraces = this.gd.data.length - this.origData.length; if (keys === null || !this.highlight.persistent && nNewTraces > 0) { var tracesToRemove = []; - for (var i = this.origData.length; i < this.gd.data.length; i++) { - tracesToRemove.push(i); + for (var i = 0; i < this.gd.data.length; i++) { + if (this.gd.data[i]._isCrosstalkTrace) tracesToRemove.push(i); } Plotly.deleteTraces(this.gd, tracesToRemove); this.groupSelections[group] = keys; @@ -678,6 +678,7 @@ TraceManager.prototype.updateSelection = function(group, keys) { // (necessary for updating frames to reflect the selection traces) trace._originalIndex = i; trace._newIndex = this.gd._fullData.length + traces.length; + trace._isCrosstalkTrace = true; traces.push(trace); } }