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 3 commits
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
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]];
if (typeof pt.pointNumber === "number") {
obj[attrsToAttach[i]] = attr[pt.pointNumber];
} else if (Array.isArray(pt.pointNumber)) {
obj[attrsToAttach[i]] = attr[pt.pointNumber[0]][pt.pointNumber[1]];
} else if (Array.isArray(pt.pointNumbers)) {
obj[attrsToAttach[i]] = pt.pointNumbers.map(function(i) { return attr[i]; });
}
}
}
return obj;
Expand Down