Skip to content

Commit 7c9b538

Browse files
authored
Merge pull request #1148 from monfera/1145-scatter-hover-bug
Fixing the pickOffset bug in non-fancy gl-scatter2d
2 parents 0e0928b + eeed987 commit 7c9b538

File tree

2 files changed

+102
-1
lines changed

2 files changed

+102
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"gl-plot2d": "^1.2.0",
7070
"gl-plot3d": "^1.5.1",
7171
"gl-pointcloud2d": "^1.0.0",
72-
"gl-scatter2d": "^1.2.1",
72+
"gl-scatter2d": "^1.2.2",
7373
"gl-scatter2d-fancy": "^1.2.1",
7474
"gl-scatter3d": "^1.0.4",
7575
"gl-select-box": "^1.0.1",

test/jasmine/tests/gl2d_click_test.js

+101
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ describe('Test hover and click interactions', function() {
9090
'autosize': true
9191
}
9292
};
93+
var mock4 = {
94+
data: [
95+
{
96+
x: [1, 2, 3, 4],
97+
y: [12, 3, 14, 4],
98+
type: 'scattergl',
99+
mode: 'markers'
100+
},
101+
{
102+
x: [4, 5, 6, 7],
103+
y: [1, 31, 24, 14],
104+
type: 'scattergl',
105+
mode: 'markers'
106+
},
107+
{
108+
x: [8, 9, 10, 11],
109+
y: [18, 13, 10, 3],
110+
type: 'scattergl',
111+
mode: 'markers'
112+
}],
113+
layout: {}
114+
};
93115

94116
var mockCopy, gd;
95117

@@ -340,6 +362,85 @@ describe('Test hover and click interactions', function() {
340362

341363
});
342364

365+
it('scattergl', function(done) {
366+
367+
var modifiedMockCopy = Lib.extendDeep({}, mock4);
368+
369+
Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)
370+
371+
.then(new Promise(function() {
372+
373+
gd.on('plotly_hover', function(data) {
374+
futureData = data;
375+
});
376+
377+
hover(435, 216);
378+
379+
window.setTimeout(function() {
380+
381+
expect(futureData.points.length).toEqual(1);
382+
383+
var pt = futureData.points[0];
384+
385+
expect(Object.keys(pt)).toEqual([
386+
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
387+
]);
388+
389+
expect(pt.x).toEqual(8);
390+
expect(pt.y).toEqual(18);
391+
expect(pt.curveNumber).toEqual(2);
392+
expect(pt.pointNumber).toEqual(0);
393+
expect(pt.fullData.length).toEqual(3);
394+
expect(typeof pt.data.uid).toEqual('string');
395+
expect(pt.xaxis.domain.length).toEqual(2);
396+
expect(pt.yaxis.domain.length).toEqual(2);
397+
398+
done();
399+
}, 350);
400+
}));
401+
});
402+
403+
it('scattergl-fancy', function(done) {
404+
405+
var modifiedMockCopy = Lib.extendDeep({}, mock4);
406+
modifiedMockCopy.data[0].mode = 'markers+lines';
407+
modifiedMockCopy.data[1].mode = 'markers+lines';
408+
modifiedMockCopy.data[2].mode = 'markers+lines';
409+
410+
Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)
411+
412+
.then(new Promise(function() {
413+
414+
gd.on('plotly_hover', function(data) {
415+
futureData = data;
416+
});
417+
418+
hover(435, 216);
419+
420+
window.setTimeout(function() {
421+
422+
expect(futureData.points.length).toEqual(1);
423+
424+
var pt = futureData.points[0];
425+
426+
expect(Object.keys(pt)).toEqual([
427+
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
428+
]);
429+
430+
expect(pt.x).toEqual(8);
431+
expect(pt.y).toEqual(18);
432+
expect(pt.curveNumber).toEqual(2);
433+
expect(pt.pointNumber).toEqual(0);
434+
expect(pt.fullData.length).toEqual(3);
435+
expect(typeof pt.data.uid).toEqual('string');
436+
expect(pt.xaxis.domain.length).toEqual(2);
437+
expect(pt.yaxis.domain.length).toEqual(2);
438+
439+
done();
440+
}, 350);
441+
}));
442+
});
443+
343444
it('contourgl', function(done) {
344445

345446
var modifiedMockCopy = Lib.extendDeep({}, mock3);

0 commit comments

Comments
 (0)