-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix ternary hover after zoom/pan events #688
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3b1ee6b
fix ternary hover after zoom/pan events
alexcjohnson ab3a9a2
Tests: pull click and doubleClick out into assets
alexcjohnson cda7f6c
appease eslint
alexcjohnson c45c074
hover on fills: constrain label to cartesian and ternary viewports
alexcjohnson a0a12d8
test clipped positioning of hover labels for scatterternary fill
alexcjohnson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,29 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { | |
var scatterPointData = scatterHover(pointData, xval, yval, hovermode); | ||
if(!scatterPointData || scatterPointData[0].index === false) return; | ||
|
||
var newPointData = scatterPointData[0]; | ||
|
||
// if hovering on a fill, we don't show any point data so the label is | ||
// unchanged from what scatter gives us. | ||
if(scatterPointData[0].index === undefined) return scatterPointData; | ||
// unchanged from what scatter gives us - except that it needs to | ||
// be constrained to the trianglular plot area, not just the rectangular | ||
// area defined by the synthetic x and y axes | ||
// TODO: in some cases the vertical middle of the shape is not within | ||
// the triangular viewport at all, so the label can become disconnected | ||
// from the shape entirely. But calculating what portion of the shape | ||
// is actually visible, as constrained by the diagonal axis lines, is not | ||
// so easy and anyway we lost the information we would have needed to do | ||
// this inside scatterHover. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok with ignoring this. 👍 |
||
if(newPointData.index === undefined) { | ||
var yFracUp = 1 - (newPointData.y0 / pointData.ya._length), | ||
xLen = pointData.xa._length, | ||
xMin = xLen * yFracUp / 2, | ||
xMax = xLen - xMin; | ||
newPointData.x0 = Math.max(Math.min(newPointData.x0, xMax), xMin); | ||
newPointData.x1 = Math.max(Math.min(newPointData.x1, xMax), xMin); | ||
return scatterPointData; | ||
} | ||
|
||
var newPointData = scatterPointData[0], | ||
cdi = newPointData.cd[newPointData.index]; | ||
var cdi = newPointData.cd[newPointData.index]; | ||
|
||
newPointData.a = cdi.a; | ||
newPointData.b = cdi.b; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
So if you have, for example, a shape that goes way off the top of the plot, the label will still be centered on the visible portion rather than pinned to the top (and because of how this happens, the x position of the label could also have ended up screwy previously)
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.
Great. That sounds good.
Now that all the scatter ternary hover label testing infrastructure is in place, would you mind adding a test case for this?