Skip to content

Commit 2c219fe

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 2c219fe

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

inst/htmlwidgets/plotly.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ HTMLWidgets.widget({
1717

1818
renderValue: function(el, x, instance) {
1919

20+
console.log(instance);
21+
2022
/*
2123
/ 'inform the world' about highlighting options this is so other
2224
/ crosstalk libraries have a chance to respond to special settings
@@ -263,10 +265,13 @@ HTMLWidgets.widget({
263265
for (var i = 0; i < attrsToAttach.length; i++) {
264266
var attr = trace[attrsToAttach[i]];
265267
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]];
268+
var ptNums = pt.pointNumber || pt.pointNumbers;
269+
if (typeof ptNums === "number") {
270+
ptNums = [ptNums];
271+
}
272+
if (Array.isArray(ptNums)) {
273+
obj[attrsToAttach[i]] = ptNums.map(function(i) { return attr[i]; });
274+
}
270275
}
271276
}
272277
return obj;

0 commit comments

Comments
 (0)