Skip to content

Commit a35500a

Browse files
committed
fix trace-less scenes with 3d annotations
- this is an unreported bug, that the new strict-d3 logic uncovered.
1 parent 6c9ba1a commit a35500a

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/plots/gl3d/scene.js

+27-2
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,29 @@ function computeTraceBounds(scene, trace, bounds) {
399399
}
400400
}
401401

402+
function computeAnnotationBounds(scene, bounds) {
403+
var sceneLayout = scene.fullSceneLayout;
404+
var annotations = sceneLayout.annotations || [];
405+
406+
for(var d = 0; d < 3; d++) {
407+
var axisName = axisProperties[d];
408+
var axLetter = axisName.charAt(0);
409+
var ax = sceneLayout[axisName];
410+
411+
for(var j = 0; j < annotations.length; j++) {
412+
var ann = annotations[j];
413+
414+
if(ann.visible) {
415+
var pos = ax.r2l(ann[axLetter]);
416+
if(!isNaN(pos) && isFinite(pos)) {
417+
bounds[0][d] = Math.min(bounds[0][d], pos);
418+
bounds[1][d] = Math.max(bounds[1][d], pos);
419+
}
420+
}
421+
}
422+
}
423+
}
424+
402425
proto.plot = function(sceneData, fullLayout, layout) {
403426
// Save parameters
404427
this.plotArgs = [sceneData, fullLayout, layout];
@@ -443,18 +466,20 @@ proto.plot = function(sceneData, fullLayout, layout) {
443466
[Infinity, Infinity, Infinity],
444467
[-Infinity, -Infinity, -Infinity]
445468
];
469+
446470
for(i = 0; i < sceneData.length; ++i) {
447471
data = sceneData[i];
448472
if(data.visible !== true) continue;
449473

450474
computeTraceBounds(this, data, dataBounds);
451475
}
476+
computeAnnotationBounds(this, dataBounds);
477+
452478
var dataScale = [1, 1, 1];
453479
for(j = 0; j < 3; ++j) {
454480
if(dataBounds[1][j] === dataBounds[0][j]) {
455481
dataScale[j] = 1.0;
456-
}
457-
else {
482+
} else {
458483
dataScale[j] = 1.0 / (dataBounds[1][j] - dataBounds[0][j]);
459484
}
460485
}

0 commit comments

Comments
 (0)