ramnathv / htmlwidgets

HTML Widgets for R
http://htmlwidgets.org
Other
783 stars 207 forks source link

htmlwidgets for shiny inputs #203

Open RicLouRiv opened 8 years ago

RicLouRiv commented 8 years ago

Hello,

Could someone point me to an example of how to use htmlwidgets to create Shiny inputs? For example, I'd like to create a slider widget based on limitslider (https://github.com/vanderlee/limitslider).

Many thanks!

timelyportfolio commented 8 years ago

@RicLouRiv, limitslider is very neat. Unfortunately, we have not fully settled on an API to make htmlwidgets act as Shiny inputs. However, in #86, you can see a very long discussion of this particularly starting here. There is some additional early discussion in #19.

jcheng5 commented 8 years ago

I'd check this out: http://shiny.rstudio.com/articles/building-inputs.html

If we decide to expand htmlwidgets to include inputs as well, it's very likely that it'll be an easy transition from a Shiny input to an htmlwidget input, as was the case for Shiny outputs to htmlwidget outputs.

RicLouRiv commented 8 years ago

Thank you both very much for your quick reply!

jrowen commented 7 years ago

I'd also express support for adding input functionality to htmlwidgets. In rhandsontable, we've bound a few change events to shiny inputs, which provides a little shiny input/output functionality. Because the input isn't bound until the table changes, it can be a bit challenging to set-up shiny apps that rely on the initial widget data for calculations.

jrowen commented 7 years ago

It would also be useful to be able to leverage shiny's registerInputHandler functionality to run custom methods that automatically convert the widget data to a data.frame.

petegordon commented 6 years ago

For anyone else that lands here, trying to learn the way to add Shiny Inputs to htmlwidgets (and how to do the JavaScript binding for interactions). @aarizvi pointed me to this blog post (section 7) and it answered my question perfectly (just add observeEvent in Shiny server, after wiring up Shiny.onInputChange() in the javascript). Good stuff!

https://deanattali.com/blog/htmlwidgets-tips/#widget-to-r-data

krlmlr commented 5 years ago

@RicLouRiv: Did you succeed in wrapping the limitslider in Shiny?

I have also found @JohnCoene's tutorial very useful: https://john-coene.com/post/how-to-build-htmlwidgets/.