-
-
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
Include values of all array attributes in hover/click/select event data #1770
Conversation
- data attributes (e.g. ids, customdata) and arrayOk ('marker.size', 'text') values of click/hover'ed points are now included in the event data (along side the pts' coords) - to do so, cache `findArrayAttributes` results in full trace object and use that cache in hover routine.
@etpinard I'm strongly in favor of doing as you propose. This is in part because events then convey pertinent information, and the API is simpler for the user. Also, the current practice of relying on attached properties on the
|
⬆️ my comments may be more pertinent to the
but doesn't include |
Yeah totally, this will make a lot of applications cleaner 🌟 |
src/plots/plots.js
Outdated
@@ -676,6 +676,9 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) { | |||
Lib.pushUnique(modules, _module); | |||
Lib.pushUnique(basePlotModules, fullTrace._module.basePlotModule); | |||
|
|||
// TODO remove findArrayAttributes calls downstream | |||
fullTrace._arrayAttrs = PlotSchema.findArrayAttributes(fullTrace); |
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.
possibly move this to calc
since we do that whenever arrays change?
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.
Good call!
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 ee1adf8
includes PRs: - #1657 - gl-vis/gl-scatter2d-sdf#5 - #1781 - #1770
- making them valid for all trace types
- no need to call on every update, when data array change is sufficient. - note that the groupby transform still need to call Plots.findArrayAttributes on its own as its transform method is called during the defaults.
- to bring its point data on-par with hover/click/unhover
@monfera good call about #1770 (comment) - see patch in 3399a58 |
Tagging this PR as |
else key = astr; | ||
|
||
if(pointData[key] === undefined) { | ||
var val = Lib.nestedProperty(trace, astr).get(); |
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.
not blocking, but if we find that this starts dragging on performance (particularly for selecting
I guess) then I suspect nestedProperty
would be the primary cost. Could possibly store these instead of attribute strings in _arrayAttrs
? It would be a little weird, since they could be referencing data arrays inside an outdated trace
if we've redrawn without a recalc, but in as far as recalc is always triggered by changing an array attribute it seems like it would be ok?
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.
Good call. I didn't notice any serious slow downs so far, so I won't address this in this PR.
This is great @etpinard - really thorough, nice to get all these harmonized with each other! 💃 |
I was about to just add
ids
andcustomdata
values in the hover/click/select event data when I realised wouldn't it be nice to include values of all array attributes? We already need to keep track of those attributes for transforms andrestyle
. That is, calls toPlotSchema.findArrayAttributes
aren't going anywhere. So, might as well cache that list and use it during picking/selecting!For example,
then hovering on
(x=1,y=2)
gives:@alexcjohnson @rreusser @monfera Thoughts?