-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
src/components/fx/hover.js
Outdated
@@ -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 && |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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])
😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b8b9395
src/components/fx/hover.js
Outdated
|
||
// Remove duplicated hoverData points | ||
// note that d3 also filters identical points in the rendering steps | ||
// TODO: use ES6 map |
There was a problem hiding this comment.
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...
There was a problem hiding this 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. 💃
Great! I'll merge as soon as the tests pass |
Nicely done! |
Fixes #4656
Codepen: https://codepen.io/antoinerg/pen/gOpKwPg
First commit simply wrap existing logic into a function. Second commit changes the existing behavior.