-
Notifications
You must be signed in to change notification settings - Fork 633
as.widget distorts htmlwidget behavior #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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 I think the Session info -------------------------------------------------------------------
setting value
version R version 3.2.3 (2015-12-10)
system x86_64, darwin13.4.0
ui X11
language (EN)
collate en_US.UTF-8
tz Asia/Tokyo
date 2016-02-12
Packages -----------------------------------------------------------------------
package * version date source
base64enc 0.1-3 2015-07-28 CRAN (R 3.2.0)
colorspace 1.2-6 2015-03-11 CRAN (R 3.2.0)
curl 0.9.5 2016-01-23 CRAN (R 3.2.3)
devtools * 1.10.0.9000 2016-01-25 Github (hadley/devtools@2c08890)
digest 0.6.9 2016-01-08 CRAN (R 3.2.3)
fortunes 1.5-2 2013-12-14 CRAN (R 3.2.0)
ggplot2 * 2.0.0.9001 2016-02-09 local
git2r 0.13.1 2015-12-10 CRAN (R 3.2.2)
gridExtra 2.0.0 2015-07-14 CRAN (R 3.2.0)
gtable 0.1.2 2012-12-05 CRAN (R 3.2.0)
htmltools 0.3 2015-12-29 CRAN (R 3.2.3)
htmlwidgets * 0.5.2 2016-02-12 Github (ramnathv/htmlwidgets@791cb69)
httr 1.1.0 2016-01-28 CRAN (R 3.2.3)
jsonlite 0.9.19 2015-11-28 CRAN (R 3.2.2)
knitr 1.12.3 2016-01-22 CRAN (R 3.2.3)
magrittr 1.5 2014-11-22 CRAN (R 3.2.0)
memoise 1.0.0 2016-01-29 CRAN (R 3.2.3)
munsell 0.4.2 2013-07-11 CRAN (R 3.2.0)
plotly * 2.4.3 2016-02-12 Github (ropensci/plotly@2b9d003)
plyr 1.8.3 2015-06-12 CRAN (R 3.2.0)
R6 2.1.2 2016-01-26 CRAN (R 3.2.3)
Rcpp 0.12.3 2016-01-10 CRAN (R 3.2.3)
scales 0.3.0.9000 2016-02-10 local
viridis 0.3.2 2015-12-31 CRAN (R 3.2.3)
withr 1.0.1 2016-02-04 CRAN (R 3.2.3)
yaml 2.1.13 2014-06-12 CRAN (R 3.2.0) |
The
as.widget
function seems to be distorting widget behavior for more recently introduced functionality likeonRender
. If I remember correctly, theas.widget
mechanism was introduced so that piping withdplyr
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 callas.widget
first before callingonRender
. Simply writingp %>% 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 withrenderPlotly
, since it applies theas.widget
function explicitly toexpr
. So I cannot pass a widget object torenderPlotly
.My solution to this problem as to write a
renderPlotly2
function that removes theas.widget
call. I believe this behavior can be incorporated inrenderPlotly
directly by doing two things:as.widget
an S3 method.as.widget.data.frame
is the currentas.widget
functionas.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.The text was updated successfully, but these errors were encountered: