Search code examples
rshinyrstudiogooglevis

Embedding a Google Chart with iframe


So basically I am trying to either use the googleViz package and/or just embed a published google chart within a tabPaenl as an iframe and then have it automatically adjust to fit within the tabPanel embedded within the respective tabPanel in an R Shiny Web App. Any thoughts and/or suggestions would be awesome.

so I tried just using googleVis package and it stops the r-shiny app from loading because googleVis wants to open a graph in a separate webpage.

Basically I have a fluidRow that has to tabBoxes

                  fluidRow(
                    tabBox(
                      title = "Visualization Trends",
                      # The id lets us use input$tabset1 on the server to find the current tab
                      id = "tabset1", height = "500px",
                      tabPanel("First Response", 
                               "First Tab Content 1",
              I WANT TO EMBED THE CHART HERE
                               ),
                      tabPanel("Case Closure", "First Tab Content 2"),
                      tabPanel("SLA Met", "First Tab Content 3"),
                      tabPanel("SLA Missed", "Insert SLA Misses Content"),
                      tabPanel("Overall CR & MW", "Insert Google Chart")

The actual results have not been useful, and I am kind of stuck so I really just need some direction more than anything else.


Solution

  • So, this wasn't as hard as I thought it would be. In order to embed the chart you have to publish it first and then select the embed option. You then copy all of the content with

    <iframe>some_embedded_content<iframe>
    

    After you copy this you can then embed it within a tabBox Panel as such:

                          fluidRow(
                        tabBox(
                          title = "Visualization Trends",
                          # The id lets us use input$tabset1 on the server to find the current tab
                          id = "tabset1", height = "500px",
                          tabPanel("First Response",
                                   HTML('<iframe width="600" height="371" seamless frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/e/2PACX-1vRNxLt1gp1TRc7sB83xjGpXLcLLUq8xH0B9iv1/pubchart?oid=1201606802&amp;format=interactive"></iframe>')
    
                                   )