Skip to content

Commit 9c35675

Browse files
committed
do not remove nodes in Drawing.translatePoints
- handle that in scatter/plot.js - call Drawing.pointStyle and Drawing.translatePoints on enter selection to ensure that added point are drawn in with a smooth transition
1 parent 5fa1e97 commit 9c35675

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/components/drawing/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ drawing.setRect = function(s, x, y, w, h) {
4747
s.call(drawing.setPosition, x, y).call(drawing.setSize, w, h);
4848
};
4949

50-
/** Translate / remove node
50+
/** Translate node
5151
*
5252
* @param {object} d : calcdata point item
5353
* @param {sel} sel : d3 selction of node to translate
@@ -56,7 +56,7 @@ drawing.setRect = function(s, x, y, w, h) {
5656
*
5757
* @return {boolean} :
5858
* true if selection got translated
59-
* false if selection got removed
59+
* false if selection could not get translated
6060
*/
6161
drawing.translatePoint = function(d, sel, xa, ya) {
6262
// put xp and yp into d if pixel scaling is already done
@@ -71,7 +71,6 @@ drawing.translatePoint = function(d, sel, xa, ya) {
7171
sel.attr('transform', 'translate(' + x + ',' + y + ')');
7272
}
7373
} else {
74-
sel.remove();
7574
return false;
7675
}
7776

src/traces/scatter/plot.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,11 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
420420
.classed('point', true);
421421

422422
if(hasTransition) {
423-
enter.style('opacity', 0).transition()
423+
enter
424+
.call(Drawing.pointStyle, trace)
425+
.call(Drawing.translatePoints, xa, ya, trace)
426+
.style('opacity', 0)
427+
.transition()
424428
.style('opacity', 1);
425429
}
426430

@@ -440,6 +444,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
440444
if(trace.customdata) {
441445
el.classed('plotly-customdata', d.data !== null && d.data !== undefined);
442446
}
447+
} else {
448+
sel.remove();
443449
}
444450
});
445451

0 commit comments

Comments
 (0)