Skip to content

Commit eb594d1

Browse files
committedJun 6, 2018
🌴 *-regl2d init / reinit when no-webgl
1 parent 1d3cc91 commit eb594d1

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed
 

‎src/traces/scattergl/index.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function sceneUpdate(gd, subplot) {
166166
var scene = subplot._scene;
167167
var fullLayout = gd._fullLayout;
168168

169-
var reset = {
169+
var resetOpts = {
170170
// number of traces in subplot, since scene:subplot → 1:1
171171
count: 0,
172172
// whether scene requires init hook in plot call (dirty plot call)
@@ -181,7 +181,7 @@ function sceneUpdate(gd, subplot) {
181181
errorYOptions: []
182182
};
183183

184-
var first = {
184+
var initOpts = {
185185
selectBatch: null,
186186
unselectBatch: null,
187187
// regl- component stubs, initialized in dirty plot call
@@ -193,7 +193,11 @@ function sceneUpdate(gd, subplot) {
193193
};
194194

195195
if(!subplot._scene) {
196-
scene = subplot._scene = Lib.extendFlat({}, reset, first);
196+
scene = subplot._scene = {};
197+
198+
scene.init = function init() {
199+
Lib.extendFlat(scene, initOpts, resetOpts);
200+
};
197201

198202
// apply new option to all regl components (used on drag)
199203
scene.update = function update(opt) {
@@ -306,7 +310,7 @@ function sceneUpdate(gd, subplot) {
306310

307311
// In case if we have scene from the last calc - reset data
308312
if(!scene.dirty) {
309-
Lib.extendFlat(scene, reset);
313+
Lib.extendFlat(scene, resetOpts);
310314
}
311315

312316
return scene;
@@ -328,10 +332,7 @@ function plot(gd, subplot, cdata) {
328332

329333
var success = prepareRegl(gd, ['ANGLE_instanced_arrays', 'OES_element_index_uint']);
330334
if(!success) {
331-
scene.error2d = false;
332-
scene.line2d = false;
333-
scene.scatter2d = false;
334-
scene.fill2d = false;
335+
scene.init();
335336
return;
336337
}
337338

‎test/jasmine/bundle_tests/no_webgl_test.js

+17
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ describe('Plotly w/o WebGL support:', function() {
5757
checkNoWebGLMsg(true);
5858
return Plotly.react(gd, require('@mocks/10.json'));
5959
})
60+
.then(function() {
61+
checkNoWebGLMsg(false);
62+
63+
// one with all regl2d modules
64+
return Plotly.react(gd, [{
65+
type: 'scattergl',
66+
mode: 'lines+markers',
67+
fill: 'tozerox',
68+
y: [1, 2, 1],
69+
error_x: { value: 10 },
70+
error_y: { value: 10 }
71+
}]);
72+
})
73+
.then(function() {
74+
checkNoWebGLMsg(true);
75+
return Plotly.react(gd, require('@mocks/10.json'));
76+
})
6077
.then(function() {
6178
checkNoWebGLMsg(false);
6279
})

0 commit comments

Comments
 (0)
Please sign in to comment.