8000 Improvements to algorithm for attaching key attribute for shiny's event data, fixes #1610 by cpsievert · Pull Request #1611 · plotly/plotly.R · GitHub
[go: up one dir, main page]

Skip to content

Improvements to algorithm for attaching key attribute for shiny's event data, fixes #1610 #1611

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 4 commits into from
Sep 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improvements to algorithm for attaching key attribute for shiny's eve…
…nt data, fixes #1610

* Account for pointNumbers
* Do nothing if we don't recognize the case
  • Loading branch information
cpsievert committed Sep 3, 2019
commit 8bc36b949b162873fb15335475d49cfa1f7150ca
11 changes: 7 additions & 4 deletions inst/htmlwidgets/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,13 @@ HTMLWidgets.widget({
for (var i = 0; i < attrsToAttach.length; i++) {
var attr = trace[attrsToAttach[i]];
if (Array.isArray(attr)) {
// pointNumber can be an array (e.g., heatmaps)
// TODO: can pointNumber be 3D?
obj[attrsToAttach[i]] = typeof pt.pointNumber === "number" ?
attr[pt.pointNumber] : attr[pt.pointNumber[0]][pt.pointNumber[1]];
var ptNums = pt.pointNumber || pt.pointNumbers;
if (typeof ptNums === "number") {
ptNums = [ptNums];
}
if (Array.isArray(ptNums)) {
obj[attrsToAttach[i]] = ptNums.map(function(i) { return attr[i]; });
}
}
}
return obj;
Expand Down
0