1

I need to use javascript-visualization packages in R like plotly and dygraphs and show the generated plots in my web page. The generated plot needs to be updated whenever the user interacts with other HTML elements in the webpage.

I have considered and have been disappointed in the Shiny server way to integrate the UI with plotting because it limits the developer's way of having full control over the UI using javascript, otherwise it's great.

Until now I have found that I can embed the htmlwidgets file in an IFrame to show the plot, but as discussed in this post: Embedding an R htmlwidgets into existing webpage, and in general, Iframes are considered bad practice, and thus would like to do this: Answer to the above-linked question.

But the problem is that every time I regenerate a plot using plotly or dygraph and save them using saveWidget() function of htmlwidgets package the generated plot file has a different id for the div of the plot generated. How can I embed a div present in an external HTML file(with srcs to even more html/css/js files) whose id is changing every time I generate the plot file?

Community
  • 1
  • 1
brijs
  • 525
  • 6
  • 18
  • 1
    Do you need to actually save the widget, or are you able to let shiny render that widget real-time? I know you mentioned no iframe, however, if you do end up going the iframe route, you could pass arguments in the iframe URL and generate the visualization depending on how your users interact with HTML elements on your page. Look into the session object of shiny: http://shiny.rstudio.com/reference/shiny/latest/session.html – Bogdan Rau Aug 01 '16 at 15:30

1 Answers1

0

I would suggest I frame to pass form and using Shiny. That would not result in recreating the wheel effort in using a ready made server.