Standalone chart in production on a website?

I have a bit of a peculiar question. Does anyone here have experience with having a standalone R chart 'running in production' on a website. My organization has a professional shinyapps.io account which we use for running numerous shiny dashboards and shiny apps in production. Some of these are on their own custom domain, and some are referenced in iframes within our organization's main website.

Now our organization's webteam has put the question to us if a few of the charts within one of our dashboards could be referenced from the main website - as standalone charts.

Preferably these charts would be fully interactive a la shiny. So my question is essentially, is there a way we could have a special shiny app up and running in production and have the charts referenced through an iframe on the website for each standalone chart (or perhaps a page, containing a single slider and a barchart). The only way I know how to do this would be to create a unique shiny app for each chart, but that would be a total mess to maintain. For this approach to work there would have to be a containing app for numerous charts that get referenced.

Another approach would be to have these somewhat interactive plotly graphs. Does anyone have experience reliably generating plotly javascript that can be automatically accessed by a website content management system like drupal systematically?

Are there other approaches that could be of use? Perhaps I'm grasping at straws here, but I'd love all input and comments.

Many thanks,
Hlynur

Using plotly you can create standalone html plots with quite a lot of interactivity (even on the client side, without shiny - see e.g. this or this)

Here is an example on how to save a standalone html plot, which you can embed in an iframe later on (or share via e-mail etc.):

library(plotly)
library(htmlwidgets)
library(utils)
library(datasets)

p <- mtcars %>%
  highlight_key( ~ cyl) %>%
  plot_ly(
    type = "scatter",
    x = ~ wt,
    y = ~ mpg,
    text = ~ cyl,
    mode = "markers+text",
    textposition = "top",
    hoverinfo = "x+y",
    color = ~ factor(cyl)
  ) %>%
  highlight(on = "plotly_hover", off = "plotly_doubleclick")

p

saveWidget(p, file = "myPlot.html", selfcontained = TRUE)
browseURL("myPlot.html")
1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.