nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
368 stars 19 forks source link

Open plots in external browser by default #139

Open joshpersi opened 11 months ago

joshpersi commented 11 months ago

I find httpgd really enjoyable to use in VS Code and in my dual-monitor setup, I often open the plot viewer externally in a browser, close the plot viewer in VS code, and have my plots updating on my second monitor as I tweak my graphing code on my first monitor.

The issue with this is when I re-run my updated plotting code the plot viewer window re-opens in VS code. Is there any way to prevent httpgd from re-opening the VS Code plot viewer and to only update the external browser?

A setting to choose where or how httpgd shows plots by default may be helpful. From this post by @renkun-ken, I found the following .Rprofile code and tried to update the viewer argument to External or Browser but to no avail.

if (interactive() && Sys.getenv("TERM_PROGRAM") == "vscode") {
  if ("httpgd" %in% .packages(all.available = TRUE)) {
    options(vsc.plot = FALSE)
    options(device = function(...) {
      httpgd::hgd(silent = TRUE)
      .vsc.browser(httpgd::hgd_url(), viewer = "Beside")
    })
  }
}