Skip to content

Commit 580b819

Browse files
committed
compute axesScaleRatio inside auto and data case
1 parent a7a6c66 commit 580b819

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/plots/gl3d/scene.js

+22-24
Original file line numberDiff line numberDiff line change
@@ -730,41 +730,39 @@ proto.plot = function(sceneData, fullLayout, layout) {
730730
*/
731731
var aspectRatio;
732732
var aspectmode = fullSceneLayout.aspectmode;
733-
var axesScaleRatio;
734-
if(aspectmode === 'auto' || aspectmode === 'data') {
735-
axesScaleRatio = [1, 1, 1];
736-
733+
if(aspectmode === 'cube') {
734+
aspectRatio = [1, 1, 1];
735+
} else if(aspectmode === 'manual') {
736+
var userRatio = fullSceneLayout.aspectratio;
737+
aspectRatio = [userRatio.x, userRatio.y, userRatio.z];
738+
} else if(aspectmode === 'auto' || aspectmode === 'data') {
739+
var axesScaleRatio = [1, 1, 1];
737740
// Compute axis scale per category
738741
for(i = 0; i < 3; ++i) {
739742
axis = fullSceneLayout[axisProperties[i]];
740743
axisType = axis.type;
741744
var axisRatio = axisTypeRatios[axisType];
742745
axesScaleRatio[i] = Math.pow(axisRatio.acc, 1.0 / axisRatio.count) / dataScale[i];
743746
}
744-
}
745747

746-
if(aspectmode === 'cube') {
747-
aspectRatio = [1, 1, 1];
748-
} else if(aspectmode === 'manual') {
749-
var userRatio = fullSceneLayout.aspectratio;
750-
aspectRatio = [userRatio.x, userRatio.y, userRatio.z];
751-
} else if(aspectmode === 'auto') {
752-
var axisAutoScaleFactor = 4;
748+
if(aspectmode === 'data') {
749+
aspectRatio = axesScaleRatio;
750+
} else { // i.e. 'auto' option
751+
var axisAutoScaleFactor = 4;
753752

754-
if(Math.max.apply(null, axesScaleRatio) / Math.min.apply(null, axesScaleRatio) <= axisAutoScaleFactor) {
755-
/*
756-
* USE DATA MODE WHEN AXIS RANGE DIMENSIONS ARE RELATIVELY EQUAL
757-
*/
753+
if(Math.max.apply(null, axesScaleRatio) / Math.min.apply(null, axesScaleRatio) <= axisAutoScaleFactor) {
754+
/*
755+
* USE DATA MODE WHEN AXIS RANGE DIMENSIONS ARE RELATIVELY EQUAL
756+
*/
758757

759-
aspectRatio = axesScaleRatio;
760-
} else {
761-
/*
762-
* USE EQUAL MODE WHEN AXIS RANGE DIMENSIONS ARE HIGHLY UNEQUAL
763-
*/
764-
aspectRatio = [1, 1, 1];
758+
aspectRatio = axesScaleRatio;
759+
} else {
760+
/*
761+
* USE EQUAL MODE WHEN AXIS RANGE DIMENSIONS ARE HIGHLY UNEQUAL
762+
*/
763+
aspectRatio = [1, 1, 1];
764+
}
765765
}
766-
} else if(aspectmode === 'data') {
767-
aspectRatio = axesScaleRatio;
768766
} else {
769767
throw new Error('scene.js aspectRatio was not one of the enumerated types');
770768
}

0 commit comments

Comments
 (0)