Skip to content

Commit 2db8707

Browse files
authoredJan 23, 2018
Merge pull request #2283 from plotly/layout-resize
Layout resize fix
2 parents 536ba6f + be05b1c commit 2db8707

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed
 

‎src/plot_api/plot_api.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ Plotly.plot = function(gd, data, layout, config) {
225225
'height': '100%',
226226
'overflow': 'visible',
227227
'pointer-events': 'none'
228-
})
228+
});
229+
}
230+
231+
if(fullLayout._glcanvas) {
232+
fullLayout._glcanvas
229233
.attr('width', fullLayout.width)
230234
.attr('height', fullLayout.height);
231235
}

‎test/jasmine/tests/gl2d_plot_interact_test.js

+19
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,25 @@ describe('Test gl plot side effects', function() {
184184
})
185185
.then(done);
186186
});
187+
188+
it('should be able to resize canvas properly', function(done) {
189+
var _mock = Lib.extendDeep({}, require('@mocks/gl2d_10.json'));
190+
_mock.data[0].line.width = 5;
191+
192+
_mock.layout.width = 600;
193+
194+
Plotly.plot(gd, _mock)
195+
.then(function() {
196+
expect(gd.querySelector('.gl-canvas-context').width).toBe(600);
197+
198+
Plotly.relayout(gd, {width: 300});
199+
})
200+
.then(function() {
201+
expect(gd.querySelector('.gl-canvas-context').width).toBe(300);
202+
})
203+
.catch(fail)
204+
.then(done);
205+
});
187206
});
188207

189208
describe('Test gl2d plots', function() {

0 commit comments

Comments
 (0)
Please sign in to comment.