Skip to content

Commit 32118b0

Browse files
committed
fixup and test splom clean method
1 parent 697a127 commit 32118b0

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/traces/splom/base_plot.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,16 @@ function clean(newFullData, newFullLayout, oldFullData, oldFullLayout, oldCalcda
203203
var scene = cd0.t._scene;
204204

205205
if(trace.type === 'splom' && scene && scene.matrix) {
206-
// this below throws as error
207-
// scene.matrix.destroy();
206+
scene.matrix.destroy();
207+
cd0.t._scene = null;
208208
}
209209
}
210210
}
211211

212212
if(oldFullLayout._splomGrid &&
213213
(!newFullLayout._hasOnlyLargeSploms && oldFullLayout._hasOnlyLargeSploms)) {
214214
oldFullLayout._splomGrid.destroy();
215+
oldFullLayout._splomGrid = null;
215216
}
216217

217218
Cartesian.clean(newFullData, newFullLayout, oldFullData, oldFullLayout);

test/jasmine/tests/splom_test.js

+35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
var Lib = require('@src/lib');
22
var supplyAllDefaults = require('../assets/supply_defaults');
3+
var Plots = require('@src/plots/plots');
4+
5+
var Plotly = require('@lib');
6+
var createGraphDiv = require('../assets/create_graph_div');
7+
var destroyGraphDiv = require('../assets/destroy_graph_div');
8+
var failTest = require('../assets/fail_test');
39

410
describe('Test splom trace defaults:', function() {
511
var gd;
@@ -271,3 +277,32 @@ describe('Test splom trace defaults:', function() {
271277
expect(fullLayout.yaxis.type).toBe('date');
272278
});
273279
});
280+
281+
describe('@gl Test splom interactions:', function() {
282+
var gd;
283+
284+
beforeEach(function() {
285+
gd = createGraphDiv();
286+
});
287+
288+
afterEach(function() {
289+
Plotly.purge(gd);
290+
destroyGraphDiv();
291+
});
292+
293+
it('should destroy gl objects on Plots.cleanPlot', function(done) {
294+
Plotly.plot(gd, Lib.extendDeep({}, require('@mocks/splom_large.json'))).then(function() {
295+
expect(gd._fullLayout._splomGrid).toBeDefined();
296+
expect(gd.calcdata[0][0].t._scene).toBeDefined();
297+
298+
return Plots.cleanPlot([], {}, gd._fullData, gd._fullLayout, gd.calcdata);
299+
})
300+
.then(function() {
301+
expect(gd._fullLayout._splomGrid).toBe(null);
302+
expect(gd.calcdata[0][0].t._scene).toBe(null);
303+
})
304+
.catch(failTest)
305+
.then(done);
306+
});
307+
308+
});

0 commit comments

Comments
 (0)