Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gl3d hover bug fix - pick most recent point if two share identical position #4096

Merged
merged 4 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.1.1",
"gl-plot2d": "^1.4.2",
"gl-plot3d": "^2.2.1",
"gl-plot3d": "^2.2.2",
"gl-pointcloud2d": "^1.0.2",
"gl-scatter3d": "^1.2.2",
"gl-select-box": "^1.0.3",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions test/image/mocks/gl3d_transparent_same-depth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"data": [
{
"x": [
0,
1,
1,
0,
0,
1,
1,
0
],
"y": [
0,
0,
1,
1,
0,
0,
1,
1
],
"z": [
0,
0,
0,
0,
0,
0,
0,
0
],
"text": [
"first below",
"second below",
"third below",
"fourth below",
"first above",
"second above",
"third above",
"fourth above"
],
"type": "scatter3d",
"opacity": 0.5,
"marker": {
"opacity": 0.5,
"size": 50
}
},
{
"x": [
0,
1,
1,
0,
0,
1,
1,
0
],
"y": [
0,
0,
1,
1,
0,
0,
1,
1
],
"z": [
1,
1,
1,
1,
1,
1,
1,
1
],
"text": [
"first below",
"second below",
"third below",
"fourth below",
"first above",
"second above",
"third above",
"fourth above"
],
"type": "scatter3d",
"opacity": 0.5,
"marker": {
"opacity": 0.5,
"size": 50
}
}
],
"layout": {
"width": 400,
"height": 400,
"title": {
"text": "hover should generally pick latest<br>points on the same position<br>and display above not below"
}
}
}
33 changes: 31 additions & 2 deletions test/jasmine/tests/gl3d_hover_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mock2.data[0].surfaceaxis = 2;
mock2.layout.showlegend = true;

var mock3 = require('@mocks/gl3d_autocolorscale');
var mock4 = require('@mocks/gl3d_transparent_same-depth.json');

describe('Test gl3d trace click/hover:', function() {
var gd, ptData;
Expand All @@ -39,13 +40,16 @@ describe('Test gl3d trace click/hover:', function() {
destroyGraphDiv();
});

function assertHoverText(xLabel, yLabel, zLabel, textLabel) {
function assertHoverText(xLabel, yLabel, zLabel, textLabel, traceName) {
var content = [];
if(xLabel) content.push(xLabel);
if(yLabel) content.push(yLabel);
if(zLabel) content.push(zLabel);
if(textLabel) content.push(textLabel);
assertHoverLabelContent({nums: content.join('\n')});
assertHoverLabelContent({
name: traceName,
nums: content.join('\n')
});
}

function assertEventData(x, y, z, curveNumber, pointNumber, extra) {
Expand Down Expand Up @@ -539,4 +543,29 @@ describe('Test gl3d trace click/hover:', function() {
.catch(failTest)
.then(done);
});

it('@gl should pick latest & closest points on hover if two points overlap', function(done) {
var _mock = Lib.extendDeep({}, mock4);

function _hover() {
mouseEvent('mouseover', 0, 0);
mouseEvent('mouseover', 200, 200);
}

Plotly.plot(gd, _mock)
.then(delay(20))
.then(function() {
gd.on('plotly_hover', function(eventData) {
ptData = eventData.points[0];
});
})
.then(delay(20))
.then(_hover)
.then(delay(20))
.then(function() {
assertHoverText('x: 1', 'y: 1', 'z: 1', 'third above', 'trace 1');
})
.catch(failTest)
.then(done);
});
});