Skip to content

Commit 44bc554

Browse files
committed
add jasmine test
1 parent 13d013d commit 44bc554

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/jasmine/tests/scatter_test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,50 @@ describe('stacked area', function() {
13611361
})
13621362
.then(done, done.fail);
13631363
});
1364+
1365+
it('maintains correct fill elements when toggling trace visibility in stacked area charts', function(done) {
1366+
// Regression test for issue #7660
1367+
// When isolating, then hiding all, then showing all traces in a stacked area chart,
1368+
// fill elements should be correctly drawn for all traces.
1369+
1370+
function countNonEmptyFills() {
1371+
return d3SelectAll('.scatterlayer .js-fill').filter(function() {
1372+
var d = d3Select(this).attr('d');
1373+
return d && d !== 'M0,0Z';
1374+
}).size();
1375+
}
1376+
1377+
Plotly.newPlot(gd, [
1378+
{x: [1, 2, 3], y: [2, 1, 4], stackgroup: 'one', name: 'trace 0'},
1379+
{x: [1, 2, 3], y: [1, 1, 2], stackgroup: 'one', name: 'trace 1'},
1380+
{x: [1, 2, 3], y: [3, 0, 2], stackgroup: 'one', name: 'trace 2'}
1381+
])
1382+
.then(function() {
1383+
// Initially all 3 traces should be visible with fills
1384+
expect(countNonEmptyFills()).toBe(3, 'should have 3 fill paths initially');
1385+
1386+
// Show trace 1 only
1387+
return Plotly.restyle(gd, 'visible', ['legendonly', true, 'legendonly']);
1388+
})
1389+
.then(function() {
1390+
// Verify only one fill is drawn (trace 1)
1391+
expect(countNonEmptyFills()).toBe(1, 'should have 1 fill path when isolating trace 1');
1392+
// Hide all traces
1393+
return Plotly.restyle(gd, 'visible', ['legendonly', 'legendonly', 'legendonly']);
1394+
})
1395+
.then(function() {
1396+
// Verify no fills are drawn
1397+
expect(countNonEmptyFills()).toBe(0, 'should have 0 fill paths when hiding all traces');
1398+
// Show all traces again
1399+
return Plotly.restyle(gd, 'visible', [true, true, true]);
1400+
})
1401+
.then(function() {
1402+
// Verify all 3 fills are drawn again
1403+
// This is the step that was failing in #7660
1404+
expect(countNonEmptyFills()).toBe(3, 'should have 3 fill paths after showing all traces again');
1405+
})
1406+
.then(done, done.fail);
1407+
});
13641408
});
13651409

13661410
describe('scatter hoverPoints', function() {

0 commit comments

Comments
 (0)