diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 9296a02db31..82c815a9fee 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -225,7 +225,11 @@ Plotly.plot = function(gd, data, layout, config) { 'height': '100%', 'overflow': 'visible', 'pointer-events': 'none' - }) + }); + } + + if(fullLayout._glcanvas) { + fullLayout._glcanvas .attr('width', fullLayout.width) .attr('height', fullLayout.height); } diff --git a/test/jasmine/tests/gl2d_plot_interact_test.js b/test/jasmine/tests/gl2d_plot_interact_test.js index c311dfca182..625250504ca 100644 --- a/test/jasmine/tests/gl2d_plot_interact_test.js +++ b/test/jasmine/tests/gl2d_plot_interact_test.js @@ -184,6 +184,25 @@ describe('Test gl plot side effects', function() { }) .then(done); }); + + it('should be able to resize canvas properly', function(done) { + var _mock = Lib.extendDeep({}, require('@mocks/gl2d_10.json')); + _mock.data[0].line.width = 5; + + _mock.layout.width = 600; + + Plotly.plot(gd, _mock) + .then(function() { + expect(gd.querySelector('.gl-canvas-context').width).toBe(600); + + Plotly.relayout(gd, {width: 300}); + }) + .then(function() { + expect(gd.querySelector('.gl-canvas-context').width).toBe(300); + }) + .catch(fail) + .then(done); + }); }); describe('Test gl2d plots', function() {