Skip to content

Commit

Permalink
Merge pull request #3924 from plotly/phx-241
Browse files Browse the repository at this point in the history
fix for ScatterGL hover and click events give the 'top' point instead of the 'bottom' point
  • Loading branch information
archmoj authored May 31, 2019
2 parents c9b377d + f72389d commit 297ecb7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/traces/scattergl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ function hoverPoints(pointData, xval, yval, hovermode) {
}
}
} else {
for(i = 0; i < ids.length; i++) {
for(i = ids.length - 1; i > -1; i--) {
ptx = x[ids[i]];
pty = y[ids[i]];
dx = xa.c2p(ptx) - xpx;
Expand Down
41 changes: 41 additions & 0 deletions test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,47 @@ describe('Test hover and click interactions', function() {
.then(done);
});

it('@gl should show last point data for overlapped scattergl points with hovermode set to closest', function(done) {
var _mock = Lib.extendDeep({}, mock1);
_mock.data[0].hovertext = 'text';
_mock.data[0].hovertext = 'HoVeRtExT';
_mock.layout.hovermode = 'closest';

var run = makeRunner([200, 200], {
x: 2,
y: 0,
label: ['(2, 0)\nTRUE', null],
curveNumber: 0,
pointNumber: 3,
bgcolor: 'rgb(31, 119, 180)',
bordercolor: 'rgb(255, 255, 255)',
fontSize: 13,
fontFamily: 'Arial',
fontColor: 'rgb(255, 255, 255)'
}, {
msg: 'scattergl with hovertext'
});

Plotly.plot(gd, {
data: [{
text: ['', 'FALSE', '', 'TRUE'],
x: [1, 2, 3, 2],
y: [0, 0, 0, 0],
type: 'scattergl',
mode: 'markers',
marker: { size: 40 }
}],
layout: {
width: 400,
height: 400,
hovermode: 'closest'
}
})
.then(run)
.catch(failTest)
.then(done);
});

it('@gl should output correct event data for pointcloud', function(done) {
var _mock = Lib.extendDeep({}, mock2);

Expand Down

0 comments on commit 297ecb7

Please sign in to comment.