@@ -41,7 +41,7 @@ function render(scene) {
41
41
svgContainer . setAttributeNS ( null , 'viewBox' , '0 0 ' + width + ' ' + height ) ;
42
42
svgContainer . setAttributeNS ( null , 'width' , width ) ;
43
43
svgContainer . setAttributeNS ( null , 'height' , height ) ;
44
-
44
+
45
45
computeTickMarks ( scene ) ;
46
46
scene . glplot . axes . update ( scene . axesOptions ) ;
47
47
@@ -383,6 +383,13 @@ function computeTraceBounds(scene, trace, bounds) {
383
383
}
384
384
}
385
385
386
+ function isCloseToZero ( a ) {
387
+ if ( Math . abs ( a ) > Number . MIN_VALUE ) { // the smallest positive numeric value representable in JavaScript
388
+ return false ;
389
+ }
390
+ return true ;
391
+ }
392
+
386
393
proto . plot = function ( sceneData , fullLayout , layout ) {
387
394
388
395
// Save parameters
@@ -399,7 +406,7 @@ proto.plot = function(sceneData, fullLayout, layout) {
399
406
else this . glplot . clearColor = [ 0 , 0 , 0 , 0 ] ;
400
407
401
408
this . glplot . snapToData = true ;
402
-
409
+
403
410
// Update layout
404
411
this . fullLayout = fullLayout ;
405
412
this . fullSceneLayout = fullSceneLayout ;
@@ -421,7 +428,7 @@ proto.plot = function(sceneData, fullLayout, layout) {
421
428
// Convert scene data
422
429
if ( ! sceneData ) sceneData = [ ] ;
423
430
else if ( ! Array . isArray ( sceneData ) ) sceneData = [ sceneData ] ;
424
-
431
+
425
432
// Compute trace bounding box
426
433
var dataBounds = [
427
434
[ Infinity , Infinity , Infinity ] ,
@@ -435,19 +442,10 @@ proto.plot = function(sceneData, fullLayout, layout) {
435
442
}
436
443
var dataScale = [ 1 , 1 , 1 ] ;
437
444
for ( j = 0 ; j < 3 ; ++ j ) {
438
- if ( dataBounds [ 0 ] [ j ] > dataBounds [ 1 ] [ j ] ) {
439
- dataScale [ j ] = 1.0 ;
440
- }
441
- else {
442
- if ( dataBounds [ 1 ] [ j ] === dataBounds [ 0 ] [ j ] ) {
443
- dataScale [ j ] = 1.0 ;
444
- }
445
- else {
446
- dataScale [ j ] = 1.0 / ( dataBounds [ 1 ] [ j ] - dataBounds [ 0 ] [ j ] ) ;
447
- }
448
- }
445
+ var diff = dataBounds [ 1 ] [ j ] - dataBounds [ 0 ] [ j ] ;
446
+ if ( ! isCloseToZero ( diff ) ) dataScale [ j ] = 1.0 / diff ;
449
447
}
450
-
448
+
451
449
// Save scale
452
450
this . dataScale = dataScale ;
453
451
@@ -558,7 +556,14 @@ proto.plot = function(sceneData, fullLayout, layout) {
558
556
} else {
559
557
var d = sceneBounds [ 1 ] [ i ] - sceneBounds [ 0 ] [ i ] ;
560
558
sceneBounds [ 0 ] [ i ] -= d / 32.0 ;
561
- sceneBounds [ 1 ] [ i ] += d / 32.0 ;
559
+ sceneBounds [ 1 ] [ i ] += d / 32.0 ;
560
+ }
561
+
562
+ if ( axis . autorange === 'reversed' ) {
563
+ // swap bounds:
564
+ var tmp = sceneBounds [ 0 ] [ i ] ;
565
+ sceneBounds [ 0 ] [ i ] = sceneBounds [ 1 ] [ i ] ;
566
+ sceneBounds [ 1 ] [ i ] = tmp ;
562
567
}
563
568
} else {
564
569
var range = axis . range ;
@@ -570,14 +575,14 @@ proto.plot = function(sceneData, fullLayout, layout) {
570
575
sceneBounds [ 1 ] [ i ] += 1 ;
571
576
}
572
577
axisDataRange [ i ] = sceneBounds [ 1 ] [ i ] - sceneBounds [ 0 ] [ i ] ;
573
-
578
+
574
579
// Update plot bounds
575
580
this . glplot . bounds [ 0 ] [ i ] = sceneBounds [ 0 ] [ i ] * dataScale [ i ] ;
576
581
this . glplot . bounds [ 1 ] [ i ] = sceneBounds [ 1 ] [ i ] * dataScale [ i ] ;
577
582
}
578
-
583
+
579
584
var axesScaleRatio = [ 1 , 1 , 1 ] ;
580
-
585
+
581
586
// Compute axis scale per category
582
587
for ( i = 0 ; i < 3 ; ++ i ) {
583
588
axis = fullSceneLayout [ axisProperties [ i ] ] ;
0 commit comments