@@ -65,24 +65,24 @@ function LineWithMarkers(scene, uid) {
65
65
[ 0 , 0 , 0 , 1 ] ,
66
66
[ 0 , 0 , 0 , 1 ] ,
67
67
[ 0 , 0 , 0 , 1 ] ] ,
68
- dashes : [ 1 ]
69
- } ) ;
68
+ dashes : [ 1 ] ,
69
+ } , 0 ) ;
70
70
71
71
this . errorX = this . initObject ( createError , {
72
72
positions : new Float64Array ( 0 ) ,
73
73
errors : new Float64Array ( 0 ) ,
74
74
lineWidth : 1 ,
75
75
capSize : 0 ,
76
76
color : [ 0 , 0 , 0 , 1 ]
77
- } ) ;
77
+ } , 1 ) ;
78
78
79
79
this . errorY = this . initObject ( createError , {
80
80
positions : new Float64Array ( 0 ) ,
81
81
errors : new Float64Array ( 0 ) ,
82
82
lineWidth : 1 ,
83
83
capSize : 0 ,
84
84
color : [ 0 , 0 , 0 , 1 ]
85
- } ) ;
85
+ } , 2 ) ;
86
86
87
87
var scatterOptions0 = {
88
88
positions : new Float64Array ( 0 ) ,
@@ -97,24 +97,23 @@ function LineWithMarkers(scene, uid) {
97
97
borderColor : [ 0 , 0 , 0 , 1 ]
98
98
} ;
99
99
100
- this . scatter = this . initObject ( createScatter , scatterOptions0 ) ;
101
- this . fancyScatter = this . initObject ( createFancyScatter , scatterOptions0 ) ;
100
+ this . scatter = this . initObject ( createScatter , scatterOptions0 , 3 ) ;
101
+ this . fancyScatter = this . initObject ( createFancyScatter , scatterOptions0 , 4 ) ;
102
102
}
103
103
104
104
var proto = LineWithMarkers . prototype ;
105
105
106
- proto . initObject = function ( createFn , options ) {
106
+ proto . initObject = function ( createFn , options , index ) {
107
107
var _this = this ;
108
108
var glplot = _this . scene . glplot ;
109
109
var options0 = Lib . extendFlat ( { } , options ) ;
110
110
var obj = null ;
111
111
112
- // TODO how to handle ordering ???
113
-
114
112
function update ( ) {
115
113
if ( ! obj ) {
116
114
obj = createFn ( glplot , options ) ;
117
115
obj . _trace = _this ;
116
+ obj . _index = index ;
118
117
}
119
118
obj . update ( options ) ;
120
119
return obj ;
@@ -254,12 +253,6 @@ function _convertColor(colors, opacities, count) {
254
253
return result ;
255
254
}
256
255
257
- /* Order is important here to get the correct laying:
258
- * - lines
259
- * - errorX
260
- * - errorY
261
- * - markers
262
- */
263
256
proto . update = function ( options ) {
264
257
265
258
if ( options . visible !== true ) {
@@ -297,6 +290,15 @@ proto.update = function(options) {
297
290
this . updateFast ( options ) ;
298
291
}
299
292
293
+ // sort objects so that order is preserve on updates:
294
+ // - lines
295
+ // - errorX
296
+ // - errorY
297
+ // - markers
298
+ this . scene . glplot . objects . sort ( function ( a , b ) {
299
+ return a . _index - b . _index ;
300
+ } ) ;
301
+
300
302
// not quite on-par with 'scatter', but close enough for now
301
303
// does not handle the colorscale case
302
304
this . color = getTraceColor ( options , { } ) ;
0 commit comments