@@ -275,7 +275,9 @@ var relayoutCallback = function(scene) {
275
275
yrange = scene . yaxis . range ;
276
276
277
277
// Update the layout on the DIV
278
+ scene . graphDiv . layout . xaxis . autorange = scene . xaxis . autorange ;
278
279
scene . graphDiv . layout . xaxis . range = xrange . slice ( 0 ) ;
280
+ scene . graphDiv . layout . yaxis . autorange = scene . yaxis . autorange ;
279
281
scene . graphDiv . layout . yaxis . range = yrange . slice ( 0 ) ;
280
282
281
283
// Make a meaningful value to be passed on to the possible 'plotly_relayout' subscriber(s)
@@ -310,7 +312,6 @@ proto.cameraChanged = function() {
310
312
} ;
311
313
312
314
proto . destroy = function ( ) {
313
-
314
315
var traces = this . traces ;
315
316
316
317
if ( traces ) {
@@ -334,10 +335,9 @@ proto.plot = function(fullData, calcData, fullLayout) {
334
335
var glplot = this . glplot ,
335
336
pixelRatio = this . pixelRatio ;
336
337
337
- var i , j , trace ;
338
-
339
338
this . fullLayout = fullLayout ;
340
339
this . updateAxes ( fullLayout ) ;
340
+ this . updateTraces ( fullData , calcData ) ;
341
341
342
342
var width = fullLayout . width ,
343
343
height = fullLayout . height ,
@@ -351,34 +351,6 @@ proto.plot = function(fullData, calcData, fullLayout) {
351
351
canvas . height = pixelHeight ;
352
352
}
353
353
354
- // update traces
355
- for ( i = 0 ; i < fullData . length ; ++ i ) {
356
- var fullTrace = fullData [ i ] ,
357
- calcTrace = calcData [ i ] ;
358
- trace = this . traces [ fullTrace . uid ] ;
359
-
360
- if ( trace ) trace . update ( fullTrace , calcTrace ) ;
361
- else {
362
- trace = fullTrace . _module . plot ( this , fullTrace , calcTrace ) ;
363
- }
364
-
365
- this . traces [ fullTrace . uid ] = trace ;
366
- }
367
-
368
- // remove empty traces
369
- var traceIds = Object . keys ( this . traces ) ;
370
-
371
- trace_id_loop:
372
- for ( i = 0 ; i < traceIds . length ; ++ i ) {
373
- for ( j = 0 ; j < calcData . length ; ++ j ) {
374
- if ( calcData [ j ] [ 0 ] . trace . uid === traceIds [ i ] ) continue trace_id_loop;
375
- }
376
-
377
- trace = this . traces [ traceIds [ i ] ] ;
378
- trace . dispose ( ) ;
379
- delete this . traces [ traceIds [ i ] ] ;
380
- }
381
-
382
354
var options = this . glplotOptions ;
383
355
options . merge ( fullLayout ) ;
384
356
options . screenBox = [ 0 , 0 , width , height ] ;
@@ -404,16 +376,18 @@ proto.plot = function(fullData, calcData, fullLayout) {
404
376
bounds [ 0 ] = bounds [ 1 ] = Infinity ;
405
377
bounds [ 2 ] = bounds [ 3 ] = - Infinity ;
406
378
407
- traceIds = Object . keys ( this . traces ) ;
379
+ var traceIds = Object . keys ( this . traces ) ;
380
+ var ax , i ;
381
+
408
382
for ( i = 0 ; i < traceIds . length ; ++ i ) {
409
- trace = this . traces [ traceIds [ i ] ] ;
383
+ var traceObj = this . traces [ traceIds [ i ] ] ;
384
+
410
385
for ( var k = 0 ; k < 2 ; ++ k ) {
411
- bounds [ k ] = Math . min ( bounds [ k ] , trace . bounds [ k ] ) ;
412
- bounds [ k + 2 ] = Math . max ( bounds [ k + 2 ] , trace . bounds [ k + 2 ] ) ;
386
+ bounds [ k ] = Math . min ( bounds [ k ] , traceObj . bounds [ k ] ) ;
387
+ bounds [ k + 2 ] = Math . max ( bounds [ k + 2 ] , traceObj . bounds [ k + 2 ] ) ;
413
388
}
414
389
}
415
390
416
- var ax ;
417
391
for ( i = 0 ; i < 2 ; ++ i ) {
418
392
if ( bounds [ i ] > bounds [ i + 2 ] ) {
419
393
bounds [ i ] = - 1 ;
@@ -439,6 +413,43 @@ proto.plot = function(fullData, calcData, fullLayout) {
439
413
this . glplot . draw ( ) ;
440
414
} ;
441
415
416
+ proto . updateTraces = function ( fullData , calcData ) {
417
+ var traceIds = Object . keys ( this . traces ) ;
418
+ var i , j , fullTrace ;
419
+
420
+ // remove empty traces
421
+ trace_id_loop:
422
+ for ( i = 0 ; i < traceIds . length ; i ++ ) {
423
+ var oldUid = traceIds [ i ] ,
424
+ oldTrace = this . traces [ oldUid ] ;
425
+
426
+ for ( j = 0 ; j < fullData . length ; j ++ ) {
427
+ fullTrace = fullData [ j ] ;
428
+
429
+ if ( fullTrace . uid === oldUid && fullTrace . type === oldTrace . type ) {
430
+ continue trace_id_loop;
431
+ }
432
+ }
433
+
434
+ oldTrace . dispose ( ) ;
435
+ delete this . traces [ oldUid ] ;
436
+ }
437
+
438
+ // update / create trace objects
439
+ for ( i = 0 ; i < fullData . length ; i ++ ) {
440
+ fullTrace = fullData [ i ] ;
441
+
442
+ var calcTrace = calcData [ i ] ,
443
+ traceObj = this . traces [ fullTrace . uid ] ;
444
+
445
+ if ( traceObj ) traceObj . update ( fullTrace , calcTrace ) ;
446
+ else {
447
+ traceObj = fullTrace . _module . plot ( this , fullTrace , calcTrace ) ;
448
+ this . traces [ fullTrace . uid ] = traceObj ;
449
+ }
450
+ }
451
+ } ;
452
+
442
453
proto . draw = function ( ) {
443
454
if ( this . stopped ) return ;
444
455
0 commit comments