如何在Shiny App(R)中更改gvisTable的背景颜色

时间:2014-05-07 19:07:07

标签: r shiny ggvis

我无法将Shiny中的gvisTable的背景变成白色以外的任何东西。我正在尝试这个,但它不起作用:

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

1 个答案:

答案 0 :(得分:3)

您可以使用cssClassNames选项:

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