Skip to content
Merged
Changes from all 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
32 changes: 32 additions & 0 deletions inst/htmlwidgets/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,38 @@ HTMLWidgets.widget({
}


// send user input event data to dashR
// TODO: make this more consistent with Graph() props?
var dashRwidgets = window.dashRwidgets || {};
var dashRmode = typeof el.setProps === "function" &&
typeof dashRwidgets.htmlwidget === "function";
if (dashRmode) {
graphDiv.on('plotly_relayout', function(d) {
el.setProps({"input_plotly_relayout": d});
});
graphDiv.on('plotly_hover', function(d) {
el.setProps({"input_plotly_hover": eventDataWithKey(d)});
});
graphDiv.on('plotly_click', function(d) {
el.setProps({"input_plotly_click": eventDataWithKey(d)});
});
graphDiv.on('plotly_selected', function(d) {
el.setProps({"input_plotly_selected": eventDataWithKey(d)});
});
graphDiv.on('plotly_unhover', function(eventData) {
el.setProps({"input_plotly_hover": null});
});
graphDiv.on('plotly_doubleclick', function(eventData) {
el.setProps({"input_plotly_click": null});
});
// 'plotly_deselect' is code for doubleclick when in select mode
graphDiv.on('plotly_deselect', function(eventData) {
el.setProps({"input_plotly_selected": null});
el.setProps({"input_plotly_click": null});
});
}


// Given an array of {curveNumber: x, pointNumber: y} objects,
// return a hash of {
// set1: {value: [key1, key2, ...], _isSimpleKey: false},
Expand Down