Skip to content

Instantly share code, notes, and snippets.

@sckott
Last active August 29, 2015 14:00
Show Gist options
  • Save sckott/11008455 to your computer and use it in GitHub Desktop.
Save sckott/11008455 to your computer and use it in GitHub Desktop.
library("shiny")
library("plotly")
library("ggplot2")
shinyServer(function(input, output) {
output$text <- renderText({
ggiris <- qplot(Petal.Width, Sepal.Length, data=iris, color=Species)
py <- plotly("RgraphingAPI", "ektgzomjbx")
res <- py$ggplotly(ggiris)
iframe <- paste("<iframe height=\"600\" id=\"igraph\" scrolling=\"no\" seamless=\"seamless\" src=\"",
res$response$url, "\" width=\"500\" frameBorder=\"0\"></iframe>", sep = "")
iframe
})
})
library("shiny")
shinyUI(pageWithSidebar(
headerPanel(title=HTML("TaxMap"), windowTitle="TaxMap"),
sidebarPanel(
wellPanel("plotly in shiny")
),
mainPanel(
htmlOutput("text")
)
))
@henryspivey
Copy link

If you upload this to shiny servers can you get the iframe to show? I am trying to iframe a plot.ly graph into my shiny web application and I am having trouble displaying the iframed graph.

@pedrodz
Copy link

pedrodz commented Aug 18, 2014

Hi @spivotron. If you add ".embed" at the end of the plotly link, you will get an URL to embed into your Shiny app. In this case is "https://plot.ly/~sckott/22.embed". After that, you can use tags$iframe() in your ui.R to embed the plot.ly graph, for example:
mainPanel(
tags$iframe(src="https://plot.ly/~sckott/22.embed",
height=400,
width=600)
)

@pedrodz
Copy link

pedrodz commented Aug 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment