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?