Open dmurdoch opened 8 years ago
In terms of RStudio, I think we'd need to enhance our viewer APIs to allow widgets to communicate that they are overwriting the existing display rather than creating a new one. So we'd need some new APIs in htmlwidgets then RStudio would need to respect them. This isn't on our short term work plan but we'll note this as a desired enhancement.
For R Markdown it may be that knitr could do something for htmlwidgets w/ fig.keep
. @yihui Is this something we could do relatively easily?
You asked about it in #141. The answer then was using the "proxy" model like what the leaflet or DT package does in Shiny apps. It is easier to do incremental rendering in Shiny because you can manipulate the widget by sending more data or instructions to it. For rendering in static R Markdown documents, I think we will need some changes in the htmlwidgets package, so that a new widget can be built on top of an existing one (e.g. clone the widget to a new div, and modify it). I'm not quite sure how feasible the implementation is, but I guess it is not impossible. This does not seem to be relevant to knitr. RStudio viewer definitely needs some APIs for users to manipulate an existing widget.
I'm not sure if this is an RStudio or knitr or Rmarkdown or htmlwidget issue. I asked about it a few months ago (I forget where), and I think the answer was that it was not possible. I'm hoping things have changed.
Is is possible to set things up so that when an htmlwidget prints, it replaces the currently displayed widget in the RStudio viewer, rather than adding another view to the history? In similar circumstances in an R Markdown document, you'd get just one display at the end of the code chunk (unless you wanted to see all intermediate values using chunk option `fig.keep = "all", or did a second high level plot).
The reason I want this is for
rgl
. The typical way to build a scene is to make a series of function calls to add things to it, often looking at it between the additions to decide what to add. I'd like to make it so that changes appear automatically, but only the final version of the graph shows up in the RStudio viewer history. In R Markdown, you should just get the final version of the scene.