Skip to content

Commit 35c5917

Browse files
committed
set setScale to noop in 3D setConvert
- this is also done in the default step - but we need to reset it here to get margin relayout calls to not throw excpetions.
1 parent ca4ab42 commit 35c5917

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/plots/gl3d/scene.js

+1
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ proto.setConvert = function() {
714714
for(var i = 0; i < 3; ++i) {
715715
var ax = this.fullSceneLayout[axisProperties[i]];
716716
Axes.setConvert(ax, this.fullLayout);
717+
ax.setScale = Lib.noop;
717718
}
718719
};
719720

test/jasmine/tests/gl_plot_interact_test.js

+50
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var Drawing = require('@src/components/drawing');
77

88
var createGraphDiv = require('../assets/create_graph_div');
99
var destroyGraphDiv = require('../assets/destroy_graph_div');
10+
var fail = require('../assets/fail_test');
1011
var mouseEvent = require('../assets/mouse_event');
1112
var selectButton = require('../assets/modebar_button');
1213
var customMatchers = require('../assets/custom_matchers');
@@ -631,6 +632,55 @@ describe('Test gl3d drag and wheel interactions', function() {
631632
});
632633
});
633634

635+
describe('Test gl3d relayout calls', function() {
636+
var gd;
637+
638+
beforeEach(function() {
639+
gd = createGraphDiv();
640+
});
641+
642+
afterEach(function() {
643+
Plotly.purge(gd);
644+
destroyGraphDiv();
645+
});
646+
647+
it('should be able to adjust margins', function(done) {
648+
var w = 500;
649+
var h = 500;
650+
651+
function assertMargins(t, l, b, r) {
652+
var div3d = document.getElementById('scene');
653+
expect(parseFloat(div3d.style.top)).toEqual(t, 'top');
654+
expect(parseFloat(div3d.style.left)).toEqual(l, 'left');
655+
expect(h - parseFloat(div3d.style.height) - t).toEqual(b, 'bottom');
656+
expect(w - parseFloat(div3d.style.width) - l).toEqual(r, 'right');
657+
}
658+
659+
Plotly.newPlot(gd, [{
660+
type: 'scatter3d',
661+
x: [1, 2, 3],
662+
y: [1, 2, 3],
663+
z: [1, 2, 1]
664+
}], {
665+
width: w,
666+
height: h
667+
})
668+
.then(function() {
669+
assertMargins(100, 80, 80, 80);
670+
671+
return Plotly.relayout(gd, 'margin', {
672+
l: 0, t: 0, r: 0, b: 0
673+
});
674+
})
675+
.then(function() {
676+
assertMargins(0, 0, 0, 0);
677+
})
678+
.catch(fail)
679+
.then(done);
680+
});
681+
682+
});
683+
634684
describe('Test gl2d plots', function() {
635685
var gd;
636686

0 commit comments

Comments
 (0)