Title: as.widget distorts htmlwidget behavior · Issue #449 · plotly/plotly.R · GitHub
Open Graph Title: as.widget distorts htmlwidget behavior · Issue #449 · plotly/plotly.R
X Title: as.widget distorts htmlwidget behavior · Issue #449 · plotly/plotly.R
Description: 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 ...
Open Graph Description: 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 pipin...
X Description: 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 pipin...
Opengraph URL: https://github.com/plotly/plotly.R/issues/449
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"as.widget distorts htmlwidget behavior","articleBody":"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.\n\nFor 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 %\u003e% onRender(...)` will not work.\n\n``` r\nlibrary(plotly)\nset.seed(100)\nd \u003c- diamonds[sample(nrow(diamonds), 1000), ]\np \u003c- plot_ly(d, x = carat, y = price, text = paste(\"Clarity: \", clarity),\n mode = \"markers\", color = carat, size = carat\n) \nas.widget(p) %\u003e% \n onRender(\"function(el, x){\n el.on('plotly_hover', function(data){\n console.log(data)\n })\n }\")\n```\n\nThis 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`.\n\nMy 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:\n1. Make `as.widget` an S3 method.\n2. `as.widget.data.frame` is the current `as.widget` function\n3. `as.widget.htmlwidget` would be the identity function.\n\n@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.\n","author":{"url":"https://github.com/ramnathv","@type":"Person","name":"ramnathv"},"datePublished":"2016-02-02T21:19:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/449/plotly.R/issues/449"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:932f971e-c2ed-0ae6-4cb0-2d2b840298ce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80C6:DDD15:204B67B:2E660FA:6A58E7E5 |
| html-safe-nonce | 60e5265079e221d6c72d8cfcf0a848cdffebb09a55745dc66650a14c9448b81b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEM2OkRERDE1OjIwNEI2N0I6MkU2NjBGQTo2QTU4RTdFNSIsInZpc2l0b3JfaWQiOiIzMzc0ODg3OTY2MTM3MTgyMTgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4cfa5b7d42a44f2647436424748e912a0f021925779ca5eeebaf0a021f58247e |
| hovercard-subject-tag | issue:130820270 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.R/449/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1bf39cfb572ffddcf78098f4e19833400c31c46fb69de976619b3170401f7205/plotly/plotly.R/issues/449 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1bf39cfb572ffddcf78098f4e19833400c31c46fb69de976619b3170401f7205/plotly/plotly.R/issues/449 |
| og:image:alt | 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 pipin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ramnathv |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.R git https://github.com/plotly/plotly.R.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579179 |
| octolytics-dimension-repository_nwo | plotly/plotly.R |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579179 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.R |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width