Skip to content

Commit 0d523d4

Browse files
committed
do not create WebGL ctx in 'pick' canvas on graphs w/o parcoords
- so that we create two (not three) contexts in scattergl graph as we in versions before 1.36.0
1 parent 851bcd6 commit 0d523d4

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/lib/prepare_regl.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ var createRegl = require('regl');
2323
* @param {array} extensions : list of extension to pass to createRegl
2424
*/
2525
module.exports = function prepareRegl(gd, extensions) {
26-
gd._fullLayout._glcanvas.each(function(d) {
26+
var fullLayout = gd._fullLayout;
27+
28+
fullLayout._glcanvas.each(function(d) {
2729
if(d.regl) return;
30+
// only parcoords needs pick layer
31+
if(d.pick && !fullLayout._has('parcoords')) return;
2832

2933
d.regl = createRegl({
3034
canvas: this,

test/jasmine/tests/gl2d_plot_interact_test.js

+14
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,20 @@ describe('@gl Test gl2d plots', function() {
948948
.catch(failTest)
949949
.then(done);
950950
});
951+
952+
it('should create two WebGL context per graph', function(done) {
953+
var fig = Lib.extendDeep({}, require('@mocks/gl2d_stacked_subplots.json'));
954+
955+
Plotly.plot(gd, fig).then(function() {
956+
var cnt = 0;
957+
d3.select(gd).selectAll('canvas').each(function(d) {
958+
if(d.regl) cnt++;
959+
});
960+
expect(cnt).toBe(2);
961+
})
962+
.catch(failTest)
963+
.then(done);
964+
});
951965
});
952966

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

test/jasmine/tests/parcoords_test.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,8 @@ describe('@gl parcoords Lifecycle methods', function() {
770770
});
771771

772772
describe('@gl parcoords basic use', function() {
773-
var mockCopy,
774-
gd;
773+
var mockCopy;
774+
var gd;
775775

776776
beforeEach(function(done) {
777777
mockCopy = Lib.extendDeep({}, mock);
@@ -789,6 +789,14 @@ describe('@gl parcoords basic use', function() {
789789

790790
afterAll(purgeGraphDiv);
791791

792+
it('should create three WebGL context per graph', function() {
793+
var cnt = 0;
794+
d3.select(gd).selectAll('canvas').each(function(d) {
795+
if(d.regl) cnt++;
796+
});
797+
expect(cnt).toBe(3);
798+
});
799+
792800
it('`Plotly.plot` should have proper fields on `gd.data` on initial rendering', function() {
793801

794802
expect(gd.data.length).toEqual(1);

0 commit comments

Comments
 (0)