-
-
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
Output bounding box to hover event data #5512
Changes from 1 commit
4573f34
e817828
86a4fbe
4b04337
034779d
9a57ec3
6078118
03b22ec
17dbadd
bd6688e
ccd2c88
c41b31d
888a6ba
8100f8a
262505d
53e1b61
aa00c18
9716d7e
6ba88db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,11 @@ module.exports = function eventData(out, pt, trace) { | |
if(pt.xa) out.xaxis = pt.xa; | ||
if(pt.ya) out.yaxis = pt.ya; | ||
|
||
if ('x0' in pt) out.x0 = pt.x0; | ||
if ('x1' in pt) out.x1 = pt.x1; | ||
if ('y0' in pt) out.y0 = pt.y0; | ||
if ('y1' in pt) out.y1 = pt.y1; | ||
|
||
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. Do we need 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 think we concluded that more was better here, to make it easier for folks in Dash-land. 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. Is this correct? For vertical bars 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. Shouldn't 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.
Yes,
The final event data should contain x/y. p/s is not useful to the user for positioning other elements, and that's the purpose here. |
||
if(trace.orientation === 'h') { | ||
out.label = out.y; | ||
out.value = out.x; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,16 @@ module.exports = function eventData(pt, trace) { | |
text: pt.text, | ||
|
||
// pt.v (and pt.i below) for backward compatibility | ||
v: pt.v | ||
v: pt.v, | ||
|
||
// TODO: These coordinates aren't quite correct and don't take into account some offset | ||
// I still haven't quite located (similar to xa._offset) | ||
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. If this doesn't work correctly yet, can we just drop it and leave pie as a TODO? 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. Addressed in 03b22ec. |
||
bbox: { | ||
x0: pt.x0, | ||
x1: pt.x1, | ||
y0: pt.y0, | ||
y1: pt.y1, | ||
}, | ||
}; | ||
|
||
// Only include pointNumber if it's unambiguous | ||
|
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.
🌴 there's 7 or 8 of these... could be something like
copyCoords(pt, out)
- could even include thexa/ya
->xaxis/yaxis
part, AFAICT onlyscattercarpet
is missing that one, but I bet it wouldn't even hurt to include that.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.
Is that information already accessible through
plotly_hover
? If so, can't we just modifydcc.Graph
instead of making this PR?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.
The original mouse event is accessible in
plotly_hover
, and that contains the pointer location in various coordinate systems. But plotly.js hover events are more sophisticated, and it would be far better if we can match the plotly.js behavior with our new interface.