Skip to content

Commit 86d6a95

Browse files
committed
🔒 scattergl transform behavior
1 parent b85ffe2 commit 86d6a95

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

test/jasmine/tests/gl2d_click_test.js

+23
Original file line numberDiff line numberDiff line change
@@ -689,4 +689,27 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
689689
.catch(failTest)
690690
.then(done);
691691
});
692+
693+
it('should work on trace with enabled transforms', function(done) {
694+
var fig = Lib.extendDeep({}, require('@mocks/gl2d_transforms.json'));
695+
fig.layout.dragmode = 'select';
696+
fig.layout.margin = {t: 0, b: 0, l: 0, r: 0};
697+
fig.layout.height = 500;
698+
fig.layout.width = 500;
699+
gd = createGraphDiv();
700+
701+
Plotly.plot(gd, fig)
702+
.then(delay(100))
703+
.then(function() { return select([[100, 100], [250, 250]]); })
704+
.then(function(eventData) {
705+
assertEventData(eventData, {
706+
points: [
707+
{ x: 3, y: 4 },
708+
{ x: 2, y: 4 }
709+
]
710+
});
711+
})
712+
.catch(failTest)
713+
.then(done);
714+
});
692715
});

test/jasmine/tests/gl2d_plot_interact_test.js

+66
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,72 @@ describe('@gl Test gl2d plots', function() {
962962
.catch(failTest)
963963
.then(done);
964964
});
965+
966+
it('should handle transform traces properly (calcTransform case)', function(done) {
967+
spyOn(ScatterGl, 'calc').and.callThrough();
968+
969+
Plotly.plot(gd, [{
970+
type: 'scattergl',
971+
x: [1, 2, 3],
972+
y: [1, 2, 1],
973+
transforms: [{
974+
type: 'filter',
975+
target: 'x',
976+
operation: '>',
977+
value: 1
978+
}]
979+
}])
980+
.then(function() {
981+
expect(ScatterGl.calc).toHaveBeenCalledTimes(2);
982+
983+
var opts = gd.calcdata[0][0].t._scene.markerOptions;
984+
// length === 2 before #2677
985+
expect(opts.length).toBe(1);
986+
987+
return Plotly.restyle(gd, 'selectedpoints', [[1]]);
988+
})
989+
.then(function() {
990+
// was === 1 before #2677
991+
var scene = gd.calcdata[0][0].t._scene;
992+
expect(scene.selectBatch[0]).toEqual([0]);
993+
})
994+
.catch(failTest)
995+
.then(done);
996+
});
997+
998+
it('should handle transform traces properly (default transform case)', function(done) {
999+
spyOn(ScatterGl, 'calc').and.callThrough();
1000+
1001+
Plotly.plot(gd, [{
1002+
type: 'scattergl',
1003+
x: [1, 2, 3],
1004+
y: [1, 2, 1],
1005+
transforms: [{
1006+
type: 'groupby',
1007+
groups: ['a', 'b', 'a']
1008+
}]
1009+
}])
1010+
.then(function() {
1011+
// twice per 'expanded' trace
1012+
expect(ScatterGl.calc).toHaveBeenCalledTimes(4);
1013+
1014+
// 'scene' from opts0 and opts1 is linked to the same object,
1015+
// which has two items, one for each 'expanded' trace
1016+
var opts0 = gd.calcdata[0][0].t._scene.markerOptions;
1017+
expect(opts0.length).toBe(2);
1018+
1019+
var opts1 = gd.calcdata[1][0].t._scene.markerOptions;
1020+
expect(opts1.length).toBe(2);
1021+
1022+
return Plotly.restyle(gd, 'selectedpoints', [[1]]);
1023+
})
1024+
.then(function() {
1025+
var scene = gd.calcdata[0][0].t._scene;
1026+
expect(scene.selectBatch).toEqual([[], [0]]);
1027+
})
1028+
.catch(failTest)
1029+
.then(done);
1030+
});
9651031
});
9661032

9671033
describe('Test scattergl autorange:', function() {

0 commit comments

Comments
 (0)