You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The as.widget function seems to be distorting widget behavior for more recently introduced functionality like onRender. If I remember correctly, the as.widget mechanism was introduced so that piping with dplyr verbs works. While this is convenient, it breaks widget behavior.
For example, if I want to subscribe to the plotly_hover data, I would need to call as.widget first before calling onRender. Simply writing p %>% onRender(...) will not work.
This is a minor inconvenience. The bigger problem comes with renderPlotly on the shiny side. If I want to trigger a shiny input change on hover, I won't be able to do it with renderPlotly, since it applies the as.widget function explicitly to expr. So I cannot pass a widget object to renderPlotly.
My solution to this problem as to write a renderPlotly2 function that removes the as.widget call. I believe this behavior can be incorporated in renderPlotly directly by doing two things:
Make as.widget an S3 method.
as.widget.data.frame is the current as.widget function
as.widget.htmlwidget would be the identity function.
@cpsievert let me know what you think about this. In general, it would be good if the plotly widget is able to expose all the functionality that the base htmlwidgets package provides.
Thanks for raising this issue Ramnath. I'm on vacation for a couple weeks, but I'll get working on this right away when I'm back. BTW I'm experimenting with an interface to send plotly events to shiny in #416. I'd love to have your thoughts on it!
@ramnathv your example actually works for me using the dev version of plotly and htmlwidgets (see my session info at the bottom).
You bring up a good point about making renderPlotly() work with an htmlwidget object -- #462 fixes that.
I think the event_data() interface in #416, as opposed to onRender(), will make it much easier to access input events in shiny. That being said, I'm sure those with JS knowledge may want the flexibility of onRender(). It isn't totally clear to me how to access the input data using that approach, though, am I doing it right here? https://gist.github.com/cpsievert/9a899d6c8b83b48ae2aa
Activity
cpsievert commentedon Feb 4, 2016
Thanks for raising this issue Ramnath. I'm on vacation for a couple weeks, but I'll get working on this right away when I'm back. BTW I'm experimenting with an interface to send plotly events to shiny in #416. I'd love to have your thoughts on it!
cpsievert commentedon Feb 12, 2016
@ramnathv your example actually works for me using the dev version of plotly and htmlwidgets (see my session info at the bottom).
You bring up a good point about making
renderPlotly()work with an htmlwidget object -- #462 fixes that.I think the
event_data()interface in #416, as opposed toonRender(), will make it much easier to access input events in shiny. That being said, I'm sure those with JS knowledge may want the flexibility ofonRender(). It isn't totally clear to me how to access the input data using that approach, though, am I doing it right here? https://gist.github.com/cpsievert/9a899d6c8b83b48ae2aa