Search code examples
rgooglevisflexdashboard

How to render googlevis in flexdashboard


I'm trying to use GoogleVis with the new package FlexDashboard, which is like the intersection between a basic .Rd and shinyDashboards. It's basically a non-shiny dashboard.

Anyway, I'm trying to embed a googleVis object, which doesn't seem to be supported by default, but I can get the html to show up in the output, so there must be a way! Can we come up with some hack? Maybe combining either plot() or renderGvis() combined with some kind of hack? Ormessing with setting op <- options(gvis.plot.tag='chart')?

I have failed, but maybe someone else can figure it out?


Solution

  • Building on the awesome answer from Michal Majka at Conditional reactive logic shiny based flexdashboard you can do something like this

    ---
    title: "Test gvisTable"
    output: 
      flexdashboard::flex_dashboard:
        orientation: rows
    
    runtime: shiny
    ---
    
    ```{r setup, include=FALSE}
    library(flexdashboard)
    library(googleVis)
    
    ```
    
    Column {data-height=350}
    -----------------------------------------------------------------------
    
    ### Chart c
    
    ```{r}
    #create a ui interaction:
    uiOutput("dynamic")
    
    #render the ui:
    output$dynamic <- renderUI({ 
       htmlOutput("myTable")
    })
    
    #here is your server activity:
    output$myTable <- renderGvis({    
        gvisTable(Population )       
      })
    ```