Skip to content

Commit 81d3bf6

Browse files
committed
sort gl-vis object per trace in scene2d update traces
1 parent 18e2d2b commit 81d3bf6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/plots/gl2d/scene2d.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ proto.updateTraces = function(fullData, calcData) {
494494
this.traces[fullTrace.uid] = traceObj;
495495
}
496496
}
497+
498+
// order object per traces
499+
this.glplot.objects.sort(function(a, b) {
500+
return a._trace.index - b._trace.index;
501+
});
502+
497503
};
498504

499505
proto.emitPointAction = function(nextSelection, eventType) {

src/traces/scattergl/convert.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function LineWithMarkers(scene, uid) {
4646
this.hoverinfo = 'all';
4747
this.connectgaps = true;
4848

49+
this.index = null;
4950
this.idToIndex = [];
5051
this.bounds = [0, 0, 0, 0];
5152

@@ -103,7 +104,7 @@ function LineWithMarkers(scene, uid) {
103104

104105
var proto = LineWithMarkers.prototype;
105106

106-
proto.initObject = function(createFn, options, index) {
107+
proto.initObject = function(createFn, options, objIndex) {
107108
var _this = this;
108109
var glplot = _this.scene.glplot;
109110
var options0 = Lib.extendFlat({}, options);
@@ -113,7 +114,7 @@ proto.initObject = function(createFn, options, index) {
113114
if(!obj) {
114115
obj = createFn(glplot, options);
115116
obj._trace = _this;
116-
obj._index = index;
117+
obj._index = objIndex;
117118
}
118119
obj.update(options);
119120
return obj;
@@ -299,6 +300,9 @@ proto.update = function(options) {
299300
return a._index - b._index;
300301
});
301302

303+
// set trace index so that scene2d can sort object per traces
304+
this.index = options.index;
305+
302306
// not quite on-par with 'scatter', but close enough for now
303307
// does not handle the colorscale case
304308
this.color = getTraceColor(options, {});

0 commit comments

Comments
 (0)