Skip to content

Commit

Permalink
Merge pull request #1148 from monfera/1145-scatter-hover-bug
Browse files Browse the repository at this point in the history
Fixing the pickOffset bug in non-fancy gl-scatter2d
  • Loading branch information
etpinard authored Nov 15, 2016
2 parents 0e0928b + eeed987 commit 7c9b538
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"gl-plot2d": "^1.2.0",
"gl-plot3d": "^1.5.1",
"gl-pointcloud2d": "^1.0.0",
"gl-scatter2d": "^1.2.1",
"gl-scatter2d": "^1.2.2",
"gl-scatter2d-fancy": "^1.2.1",
"gl-scatter3d": "^1.0.4",
"gl-select-box": "^1.0.1",
Expand Down
101 changes: 101 additions & 0 deletions test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ describe('Test hover and click interactions', function() {
'autosize': true
}
};
var mock4 = {
data: [
{
x: [1, 2, 3, 4],
y: [12, 3, 14, 4],
type: 'scattergl',
mode: 'markers'
},
{
x: [4, 5, 6, 7],
y: [1, 31, 24, 14],
type: 'scattergl',
mode: 'markers'
},
{
x: [8, 9, 10, 11],
y: [18, 13, 10, 3],
type: 'scattergl',
mode: 'markers'
}],
layout: {}
};

var mockCopy, gd;

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

});

it('scattergl', function(done) {

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

Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)

.then(new Promise(function() {

gd.on('plotly_hover', function(data) {
futureData = data;
});

hover(435, 216);

window.setTimeout(function() {

expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];

expect(Object.keys(pt)).toEqual([
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
]);

expect(pt.x).toEqual(8);
expect(pt.y).toEqual(18);
expect(pt.curveNumber).toEqual(2);
expect(pt.pointNumber).toEqual(0);
expect(pt.fullData.length).toEqual(3);
expect(typeof pt.data.uid).toEqual('string');
expect(pt.xaxis.domain.length).toEqual(2);
expect(pt.yaxis.domain.length).toEqual(2);

done();
}, 350);
}));
});

it('scattergl-fancy', function(done) {

var modifiedMockCopy = Lib.extendDeep({}, mock4);
modifiedMockCopy.data[0].mode = 'markers+lines';
modifiedMockCopy.data[1].mode = 'markers+lines';
modifiedMockCopy.data[2].mode = 'markers+lines';

Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)

.then(new Promise(function() {

gd.on('plotly_hover', function(data) {
futureData = data;
});

hover(435, 216);

window.setTimeout(function() {

expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];

expect(Object.keys(pt)).toEqual([
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
]);

expect(pt.x).toEqual(8);
expect(pt.y).toEqual(18);
expect(pt.curveNumber).toEqual(2);
expect(pt.pointNumber).toEqual(0);
expect(pt.fullData.length).toEqual(3);
expect(typeof pt.data.uid).toEqual('string');
expect(pt.xaxis.domain.length).toEqual(2);
expect(pt.yaxis.domain.length).toEqual(2);

done();
}, 350);
}));
});

it('contourgl', function(done) {

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

0 comments on commit 7c9b538

Please sign in to comment.