Skip to content

Commit efad20f

Browse files
committed
fix #2791 - do not clear _glcanvas ref during layout replot edits
- Some edits may call makePlotFramework, we can't clear the ref to glcanvas there as we need to properly clear the canvases.
1 parent 32e6984 commit efad20f

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/plot_api/plot_api.js

-3
Original file line numberDiff line numberDiff line change
@@ -3265,9 +3265,6 @@ function makePlotFramework(gd) {
32653265
fullLayout._glcontainer.enter().append('div')
32663266
.classed('gl-container', true);
32673267

3268-
// That is initialized in drawFramework if there are `gl` traces
3269-
fullLayout._glcanvas = null;
3270-
32713268
fullLayout._paperdiv.selectAll('.main-svg').remove();
32723269

32733270
fullLayout._paper = fullLayout._paperdiv.insert('svg', ':first-child')

test/jasmine/tests/gl2d_plot_interact_test.js

+34
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,40 @@ describe('@gl Test gl2d plots', function() {
10331033
.catch(failTest)
10341034
.then(done);
10351035
});
1036+
1037+
it('@gl should clear canvases on *replot* edits', function(done) {
1038+
Plotly.plot(gd, [{
1039+
type: 'scattergl',
1040+
y: [1, 2, 1]
1041+
}, {
1042+
type: 'scattergl',
1043+
y: [2, 1, 2]
1044+
}])
1045+
.then(function() {
1046+
expect(gd._fullLayout._glcanvas).toBeDefined();
1047+
expect(gd._fullLayout._glcanvas.size()).toBe(3);
1048+
1049+
expect(gd._fullLayout._glcanvas.data()[0].regl).toBeDefined();
1050+
expect(gd._fullLayout._glcanvas.data()[1].regl).toBeDefined();
1051+
// this is canvas is for parcoords only
1052+
expect(gd._fullLayout._glcanvas.data()[2].regl).toBeUndefined();
1053+
1054+
spyOn(gd._fullLayout._glcanvas.data()[0].regl, 'clear').and.callThrough();
1055+
spyOn(gd._fullLayout._glcanvas.data()[1].regl, 'clear').and.callThrough();
1056+
1057+
return Plotly.update(gd,
1058+
{visible: [false]},
1059+
{'xaxis.title': 'Tsdads', 'yaxis.ditck': 0.2},
1060+
[0]
1061+
);
1062+
})
1063+
.then(function() {
1064+
expect(gd._fullLayout._glcanvas.data()[0].regl.clear).toHaveBeenCalledTimes(1);
1065+
expect(gd._fullLayout._glcanvas.data()[1].regl.clear).toHaveBeenCalledTimes(1);
1066+
})
1067+
.catch(failTest)
1068+
.then(done);
1069+
});
10361070
});
10371071

10381072
describe('Test scattergl autorange:', function() {

0 commit comments

Comments
 (0)