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

compare/unified hover include all points at same coordinate #4664

Merged
merged 3 commits into from
Mar 19, 2020
Merged

Conversation

antoinerg
Copy link
Contributor

@antoinerg antoinerg commented Mar 19, 2020

Fixes #4656

Codepen: https://codepen.io/antoinerg/pen/gOpKwPg

First commit simply wrap existing logic into a function. Second commit changes the existing behavior.

@archmoj archmoj added the bug something broken label Mar 19, 2020
@@ -625,6 +628,46 @@ function _hover(gd, evt, subplot, noHoverEvent) {

hoverData.sort(function(d1, d2) { return d1.distance - d2.distance; });

// If in compare mode, select every point at position
if(hoverData[0].length !== 0 &&
['x', 'y'].indexOf(mode) !== -1 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concerning

['x', 'y'].indexOf(mode) !== -1 

creating a dynamic array of strings just for index checking might be slow.
Could we create a constant e.g.

var XY = ['x', 'y'];

at the upper scope and reuse that here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even var XY = {x: 1, y: 1} -> if(XY[mode]) 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b8b9395


// Remove duplicated hoverData points
// note that d3 also filters identical points in the rendering steps
// TODO: use ES6 map
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can make that a TODO just yet - perhaps if & when we convert the whole syntax to ES6 we can make sure we include polyfills for this and other feature, THEN we can use it whenever we wish...

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Just a few nonblocking comments. 💃

@antoinerg
Copy link
Contributor Author

This looks great. Just a few nonblocking comments.

Great! I'll merge as soon as the tests pass

@archmoj
Copy link
Contributor

archmoj commented Mar 19, 2020

Nicely done!
💃 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compare/unified hover should include all points at same coordinate
3 participants