8000 Make use of _hasCategory method · codejets/plotly.js@c399fd9 · GitHub
[go: up one dir, main page]

Skip to content

Commit c399fd9

Browse files
committed
Make use of _hasCategory method
1 parent 7ed4484 commit c399fd9

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

src/plot_api/plot_api.js

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,24 @@ Plotly.plot = function(gd, data, layout, config) {
194194
}
195195
}
196196

197+
if(fullLayout._hasCategory('gl') && fullLayout._glcanvas.empty()) {
198+
fullLayout._glcanvas.enter().append('canvas')
199+
.attr('class', function(d) {
200+
return 'gl-canvas gl-canvas-' + d.key.replace('Layer', '');
201+
})
202+
.style('position', 'absolute')
203+
.style('top', 0)
204+
.style('left', 0)
205+
.style('width', '100%')
206+
.style('height', '100%')
207+
.style('pointer-events', 'none')
208+
.style('overflow', 'visible');
209+
}
210+
211+
fullLayout._glcanvas
212+
.attr('width', fullLayout.width)
213+
.attr('height', fullLayout.height);
214+
197215
return Lib.syncOrAsync([
198216
subroutines.layoutStyles
199217
], gd);
@@ -3029,11 +3047,10 @@ function makePlotFramework(gd) {
30293047
fullLayout._glcontainer = fullLayout._paperdiv.selectAll('.gl-container')
30303048
.data([{}]);
30313049

3032-
// FIXME: bring this constant to some plotly constants module
3033-
// it is taken from parcoords lineLayerModel
3034-
fullLayout._glcanvas = fullLayout._glcontainer.enter().append('div')
3035-
.classed('gl-container', true)
3036-
.selectAll('.gl-canvas')
3050+
fullLayout._glcontainer.enter().append('div')
3051+
.classed('gl-container', true);
3052+
3053+
fullLayout._glcanvas = fullLayout._glcontainer.selectAll('.gl-canvas')
30373054
.data([{
30383055
key: 'contextLayer'
30393056
}, {
@@ -3042,31 +3059,6 @@ function makePlotFramework(gd) {
30423059
key: 'pickLayer'
30433060
}]);
30443061

3045-
// create canvases only in case if there is at least one regl component
3046-
// FIXME: probably there is a better d3 way of doing so
3047-
for(var i = 0; i < fullLayout._modules.length; i++) {
3048-
var module = fullLayout._modules[i];
3049-
if(module.categories && module.categories.indexOf('gl') >= 0) {
3050-
fullLayout._glcanvas.enter().append('canvas')
3051-
.attr('class', function(d) {
3052-
return 'gl-canvas gl-canvas-' + d.key.replace('Layer', '');
3053-
})
3054-
.style('position', 'absolute')
3055-
.style('top', 0)
3056-
.style('left', 0)
3057-
.style('width', '100%')
3058-
.style('height', '100%')
3059-
.style('pointer-events', 'none')
3060-
.style('overflow', 'visible');
3061-
3062-
break;
3063-
}
3064-
}
3065-
3066-
fullLayout._glcanvas
3067-
.attr('width', fullLayout.width)
3068-
.attr('height', fullLayout.height);
3069-
30703062
fullLayout._paperdiv.selectAll('.main-svg').remove();
30713063

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

0 commit comments

Comments
 (0)
0