Skip to content

Commit 5a59bc7

Browse files
committed
fixup pad autorange (again)
1 parent 3d26d47 commit 5a59bc7

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

src/plots/gl3d/scene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ proto.plot = function(sceneData, fullLayout, layout) {
508508
var obj = objects[j];
509509
var objBounds = obj.bounds;
510510
var fullTrace = obj._trace.data;
511-
var pad = fullTrace._pad ? fullTrace._pad / dataScale[i] : 0;
511+
var pad = fullTrace._pad || 0;
512512

513513
sceneBounds[0][i] = Math.min(sceneBounds[0][i], objBounds[0][i] / dataScale[i] - pad);
514514
sceneBounds[1][i] = Math.max(sceneBounds[1][i], objBounds[1][i] / dataScale[i] + pad);

src/traces/cone/calc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ module.exports = function calc(gd, trace) {
3636
// stash max norm value to convert cmix/cmax -> vertexIntensityBounds
3737
trace._normMax = normMax;
3838
// stash autorange pad using max 'component' value
39-
trace._pad = Math.sqrt(compMax) / (normMax || 1);
39+
trace._pad = trace.sizemode === 'absolute' ?
40+
trace.sizeref :
41+
2 * (Math.sqrt(compMax) / (normMax || 1)) * trace.sizeref;
4042

4143
colorscaleCalc(trace, [normMin, normMax], '', 'c');
4244
};
9 Bytes
Loading
6.52 KB
Loading
-1.88 KB
Loading

test/jasmine/tests/cone_test.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('Test cone defaults', function() {
6060
});
6161
});
6262

63-
describe('@gl Test cone autorange', function() {
63+
describe('@gl Test cone autorange:', function() {
6464
var gd;
6565

6666
beforeEach(function() {
@@ -117,6 +117,55 @@ describe('@gl Test cone autorange', function() {
117117
_assertAxisRanges('scaled down',
118118
[-0.39, 4.39], [-0.39, 4.39], [-0.39, 4.39]
119119
);
120+
121+
var trace = fig.data[0];
122+
123+
var x = trace.x.slice();
124+
x.push(5);
125+
var y = trace.y.slice();
126+
y.push(5);
127+
var z = trace.z.slice();
128+
z.push(5);
129+
var u = trace.u.slice();
130+
u.push(0);
131+
var v = trace.v.slice();
132+
v.push(0);
133+
var w = trace.w.slice();
134+
w.push(0);
135+
136+
return Plotly.restyle(gd, {
137+
x: [x], y: [y], z: [z],
138+
u: [u], v: [v], w: [w]
139+
});
140+
})
141+
.then(function() {
142+
_assertAxisRanges('after adding one cone outside range but with norm-0',
143+
[-0.45, 6.45], [-0.45, 6.45], [-0.45, 6.45]
144+
);
145+
146+
return Plotly.restyle(gd, 'sizeref', 10);
147+
})
148+
.then(function() {
149+
_assertAxisRanges('after increasing sizeref',
150+
[-12.4, 18.4], [-12.4, 18.4], [-12.4, 18.4]
151+
);
152+
153+
return Plotly.restyle(gd, 'sizeref', 0.1);
154+
})
155+
.then(function() {
156+
_assertAxisRanges('after decreasing sizeref',
157+
[0.74, 5.26], [0.74, 5.26], [0.74, 5.26]
158+
);
159+
160+
return Plotly.restyle(gd, {
161+
sizemode: 'absolute',
162+
sizeref: 2
163+
});
164+
})
165+
.then(function() {
166+
_assertAxisRanges('with sizemode absolute',
167+
[-1.25, 7.25], [-1.25, 7.25], [-1.25, 7.25]
168+
);
120169
})
121170
.catch(failTest)
122171
.then(done);

0 commit comments

Comments
 (0)