Skip to content

Commit c466e69

Browse files
committed
add tests for cartesian subplot deletion
1 parent 40a0829 commit c466e69

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

test/jasmine/tests/cartesian_test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,40 @@ describe('relayout', function() {
306306
});
307307

308308
});
309+
310+
describe('subplot creation / deletion:', function() {
311+
312+
afterEach(destroyGraphDiv);
313+
314+
it('should clear orphan subplot when adding traces to blank graph', function(done) {
315+
316+
function assertCartesianSubplot(len) {
317+
expect(d3.select('.subplot.xy').size()).toEqual(len);
318+
expect(d3.select('.subplot.x2y2').size()).toEqual(len);
319+
expect(d3.select('.x2title').size()).toEqual(len);
320+
expect(d3.select('.x2title').size()).toEqual(len);
321+
expect(d3.select('.ytitle').size()).toEqual(len);
322+
expect(d3.select('.ytitle').size()).toEqual(len);
323+
}
324+
325+
Plotly.plot(createGraphDiv(), [], {
326+
xaxis: { title: 'X' },
327+
yaxis: { title: 'Y' },
328+
xaxis2: { title: 'X2', anchor: 'y2' },
329+
yaxis2: { title: 'Y2', anchor: 'x2' }
330+
})
331+
.then(function(gd) {
332+
assertCartesianSubplot(1);
333+
334+
return Plotly.addTraces(gd, [{
335+
type: 'scattergeo',
336+
lon: [10, 20, 30],
337+
lat: [20, 30, 10]
338+
}]);
339+
})
340+
.then(function() {
341+
assertCartesianSubplot(0);
342+
})
343+
.then(done);
344+
});
345+
});

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,28 @@ describe('Test gl plot interactions', function() {
363363
})
364364
.then(done);
365365
});
366+
367+
it('should clear orphan cartesian subplots on addTraces', function(done) {
368+
369+
Plotly.newPlot(gd, [], {
370+
xaxis: { title: 'X' },
371+
yaxis: { title: 'Y' }
372+
})
373+
.then(function() {
374+
return Plotly.addTraces(gd, [{
375+
type: 'scattergl',
376+
x: [1, 2, 3, 4, 5, 6, 7],
377+
y: [0, 5, 8, 9, 8, 5, 0]
378+
}]);
379+
})
380+
.then(function() {
381+
expect(d3.select('.subplot.xy').size()).toEqual(0);
382+
expect(d3.select('.xtitle').size()).toEqual(0);
383+
expect(d3.select('.ytitle').size()).toEqual(0);
384+
})
385+
.then(done);
386+
387+
});
366388
});
367389

368390
describe('gl3d event handlers', function() {

0 commit comments

Comments
 (0)