Skip to content

Commit

Permalink
Merge pull request #2793 from plotly/scattergl-replot-edits
Browse files Browse the repository at this point in the history
Do not clear _glcanvas ref during layout replot edits
  • Loading branch information
etpinard committed Jul 12, 2018
2 parents bc56819 + efad20f commit e806c64
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3243,9 +3243,6 @@ function makePlotFramework(gd) {
fullLayout._glcontainer.enter().append('div')
.classed('gl-container', true);

// That is initialized in drawFramework if there are `gl` traces
fullLayout._glcanvas = null;

fullLayout._paperdiv.selectAll('.main-svg').remove();

fullLayout._paper = fullLayout._paperdiv.insert('svg', ':first-child')
Expand Down
34 changes: 34 additions & 0 deletions test/jasmine/tests/gl2d_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,40 @@ describe('@gl Test gl2d plots', function() {
.catch(failTest)
.then(done);
});

it('@gl should clear canvases on *replot* edits', function(done) {
Plotly.plot(gd, [{
type: 'scattergl',
y: [1, 2, 1]
}, {
type: 'scattergl',
y: [2, 1, 2]
}])
.then(function() {
expect(gd._fullLayout._glcanvas).toBeDefined();
expect(gd._fullLayout._glcanvas.size()).toBe(3);

expect(gd._fullLayout._glcanvas.data()[0].regl).toBeDefined();
expect(gd._fullLayout._glcanvas.data()[1].regl).toBeDefined();
// this is canvas is for parcoords only
expect(gd._fullLayout._glcanvas.data()[2].regl).toBeUndefined();

spyOn(gd._fullLayout._glcanvas.data()[0].regl, 'clear').and.callThrough();
spyOn(gd._fullLayout._glcanvas.data()[1].regl, 'clear').and.callThrough();

return Plotly.update(gd,
{visible: [false]},
{'xaxis.title': 'Tsdads', 'yaxis.ditck': 0.2},
[0]
);
})
.then(function() {
expect(gd._fullLayout._glcanvas.data()[0].regl.clear).toHaveBeenCalledTimes(1);
expect(gd._fullLayout._glcanvas.data()[1].regl.clear).toHaveBeenCalledTimes(1);
})
.catch(failTest)
.then(done);
});
});

describe('Test scattergl autorange:', function() {
Expand Down

0 comments on commit e806c64

Please sign in to comment.