Skip to content

Commit 8bc36b9

Browse files
committed
Improvements to algorithm for attaching key attribute for shiny's event data, fixes #1610
* Account for pointNumbers * Do nothing if we don't recognize the case
1 parent 2856731 commit 8bc36b9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: inst/htmlwidgets/plotly.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,13 @@ HTMLWidgets.widget({
263263
for (var i = 0; i < attrsToAttach.length; i++) {
264264
var attr = trace[attrsToAttach[i]];
265265
if (Array.isArray(attr)) {
266-
// pointNumber can be an array (e.g., heatmaps)
267-
// TODO: can pointNumber be 3D?
268-
obj[attrsToAttach[i]] = typeof pt.pointNumber === "number" ?
269-
attr[pt.pointNumber] : attr[pt.pointNumber[0]][pt.pointNumber[1]];
266+
var ptNums = pt.pointNumber || pt.pointNumbers;
267+
if (typeof ptNums === "number") {
268+
ptNums = [ptNums];
269+
}
270+
if (Array.isArray(ptNums)) {
271+
obj[attrsToAttach[i]] = ptNums.map(function(i) { return attr[i]; });
272+
}
270273
}
271274
}
272275
return obj;

0 commit comments

Comments
 (0)