Question

I cannot get the background of the gvisTable in Shiny to be anything other than white. I am trying this, but it does not work:

gvisTable(finalTable, options = list(page='enable', 
                                     width='1400px', height='300px',
                                     backgroundColor="black"))
Was it helpful?

Solution

You can use the cssClassNames options:

require(shiny)
require(googleVis)
runApp(
  list(ui = pageWithSidebar(
    headerPanel("googleVis on Shiny"),
    sidebarPanel(
      selectInput("dataset", "Choose a dataset:",
                  choices = c("rock", "pressure", "cars"))
    ),
    mainPanel(
      htmlOutput("table")
      ,tags$head(tags$style(type="text/css", ".myTableHeadrow {background-color:red;} .myTablerow {background-color:yellow;}"))
    )
  ),
  server =function(input, output)({
    output$table <- renderGvis({
      ## Table with enabled paging
      tbl2 <- gvisTable(Population, options=list(page='enable', height=300, cssClassNames = "{headerRow: 'myTableHeadrow', tableRow: 'myTablerow'}", alternatingRowStyle = FALSE), chartid = "mytable")
      tbl2
    })    
  })
  )
)

googleVis Example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top