@@ -306,41 +306,44 @@ proto.recoverContext = function() {
306
306
307
307
var axisProperties = [ 'xaxis' , 'yaxis' , 'zaxis' ] ;
308
308
309
- function coordinateBound ( axis , coord , len , d , bounds , calendar ) {
310
- var x ;
311
- if ( ! Lib . isArrayOrTypedArray ( coord ) ) {
312
- bounds [ 0 ] [ d ] = Math . min ( bounds [ 0 ] [ d ] , 0 ) ;
313
- bounds [ 1 ] [ d ] = Math . max ( bounds [ 1 ] [ d ] , len - 1 ) ;
314
- return ;
315
- }
309
+ function computeTraceBounds ( scene , trace , bounds ) {
310
+ var sceneLayout = scene . fullSceneLayout ;
316
311
317
- for ( var i = 0 ; i < ( len || coord . length ) ; ++ i ) {
318
- if ( Lib . isArrayOrTypedArray ( coord [ i ] ) ) {
319
- for ( var j = 0 ; j < coord [ i ] . length ; ++ j ) {
320
- x = axis . d2l ( coord [ i ] [ j ] , 0 , calendar ) ;
321
- if ( ! isNaN ( x ) && isFinite ( x ) ) {
322
- bounds [ 0 ] [ d ] = Math . min ( bounds [ 0 ] [ d ] , x ) ;
323
- bounds [ 1 ] [ d ] = Math . max ( bounds [ 1 ] [ d ] , x ) ;
312
+ for ( var d = 0 ; d < 3 ; d ++ ) {
313
+ var axisName = axisProperties [ d ] ;
314
+ var axLetter = axisName . charAt ( 0 ) ;
315
+ var ax = sceneLayout [ axisName ] ;
316
+ var coords = trace [ axLetter ] ;
317
+ var calendar = trace [ axLetter + 'calendar' ] ;
318
+ var len = trace [ '_' + axLetter + 'length' ] ;
319
+
320
+ if ( ! Lib . isArrayOrTypedArray ( coords ) ) {
321
+ bounds [ 0 ] [ d ] = Math . min ( bounds [ 0 ] [ d ] , 0 ) ;
322
+ bounds [ 1 ] [ d ] = Math . max ( bounds [ 1 ] [ d ] , len - 1 ) ;
323
+ } else {
324
+ var v ;
325
+
326
+ for ( var i = 0 ; i < ( len || coords . length ) ; i ++ ) {
327
+ if ( Lib . isArrayOrTypedArray ( coords [ i ] ) ) {
328
+ for ( var j = 0 ; j < coords [ i ] . length ; ++ j ) {
329
+ v = ax . d2l ( coords [ i ] [ j ] , 0 , calendar ) ;
330
+ if ( ! isNaN ( v ) && isFinite ( v ) ) {
331
+ bounds [ 0 ] [ d ] = Math . min ( bounds [ 0 ] [ d ] , v ) ;
332
+ bounds [ 1 ] [ d ] = Math . max ( bounds [ 1 ] [ d ] , v ) ;
333
+ }
334
+ }
335
+ } else {
336
+ v = ax . d2l ( coords [ i ] , 0 , calendar ) ;
337
+ if ( ! isNaN ( v ) && isFinite ( v ) ) {
338
+ bounds [ 0 ] [ d ] = Math . min ( bounds [ 0 ] [ d ] , v ) ;
339
+ bounds [ 1 ] [ d ] = Math . max ( bounds [ 1 ] [ d ] , v ) ;
340
+ }
324
341
}
325
342
}
326
343
}
327
- else {
328
- x = axis . d2l ( coord [ i ] , 0 , calendar ) ;
329
- if ( ! isNaN ( x ) && isFinite ( x ) ) {
330
- bounds [ 0 ] [ d ] = Math . min ( bounds [ 0 ] [ d ] , x ) ;
331
- bounds [ 1 ] [ d ] = Math . max ( bounds [ 1 ] [ d ] , x ) ;
332
- }
333
- }
334
344
}
335
345
}
336
346
337
- function computeTraceBounds ( scene , trace , bounds ) {
338
- var sceneLayout = scene . fullSceneLayout ;
339
- coordinateBound ( sceneLayout . xaxis , trace . x , trace . _xlength , 0 , bounds , trace . xcalendar ) ;
340
- coordinateBound ( sceneLayout . yaxis , trace . y , trace . _ylength , 1 , bounds , trace . ycalendar ) ;
341
- coordinateBound ( sceneLayout . zaxis , trace . z , trace . _zlength , 2 , bounds , trace . zcalendar ) ;
342
- }
343
-
344
347
proto . plot = function ( sceneData , fullLayout , layout ) {
345
348
346
349
// Save parameters
0 commit comments