Skip to content

Commit e9ff0f3

Browse files
committed
Merge branch 'master' into partial-bundles
2 parents 5e9db4b + ed5bce4 commit e9ff0f3

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

inst/htmlwidgets/plotly.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ HTMLWidgets.widget({
203203
for (var i = 0; i < mapboxIDs.length; i++) {
204204
var id = mapboxIDs[i];
205205
var mapOpts = x.layout[id] || {};
206-
var args = mapOpts._fitBounds || {}
206+
var args = mapOpts._fitBounds || {};
207207
if (!args) {
208208
continue;
209209
}
@@ -301,6 +301,38 @@ HTMLWidgets.widget({
301301
}
302302

303303

304+
// send user input event data to dashR
305+
// TODO: make this more consistent with Graph() props?
306+
var dashRwidgets = window.dashRwidgets || {};
307+
var dashRmode = typeof el.setProps === "function" &&
308+
typeof dashRwidgets.htmlwidget === "function";
309+
if (dashRmode) {
310+
graphDiv.on('plotly_relayout', function(d) {
311+
el.setProps({"input_plotly_relayout": d});
312+
});
313+
graphDiv.on('plotly_hover', function(d) {
314+
el.setProps({"input_plotly_hover": eventDataWithKey(d)});
315+
});
316+
graphDiv.on('plotly_click', function(d) {
317+
el.setProps({"input_plotly_click": eventDataWithKey(d)});
318+
});
319+
graphDiv.on('plotly_selected', function(d) {
320+
el.setProps({"input_plotly_selected": eventDataWithKey(d)});
321+
});
322+
graphDiv.on('plotly_unhover', function(eventData) {
323+
el.setProps({"input_plotly_hover": null});
324+
});
325+
graphDiv.on('plotly_doubleclick', function(eventData) {
326+
el.setProps({"input_plotly_click": null});
327+
});
328+
// 'plotly_deselect' is code for doubleclick when in select mode
329+
graphDiv.on('plotly_deselect', function(eventData) {
330+
el.setProps({"input_plotly_selected": null});
331+
el.setProps({"input_plotly_click": null});
332+
});
333+
}
334+
335+
304336
// Given an array of {curveNumber: x, pointNumber: y} objects,
305337
// return a hash of {
306338
// set1: {value: [key1, key2, ...], _isSimpleKey: false},

0 commit comments

Comments
 (0)