【问题标题】:How to change background color of gvisTable in Shiny App (R)如何在 Shiny App (R) 中更改 gvisTable 的背景颜色
【发布时间】:2023-03-04 19:20:02
【问题描述】:

我无法让 Shiny 中 gvisTable 的背景不是白色。我正在尝试这个,但它不起作用:

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

【问题讨论】:

    标签: r shiny ggvis


    【解决方案1】:

    您可以使用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
        })    
      })
      )
    )
    

    【讨论】:

      猜你喜欢
      • 2021-09-16
      • 1970-01-01
      • 2018-01-04
      • 2014-03-21
      • 2013-11-16
      • 1970-01-01
      • 2021-09-19
      • 2019-02-11
      • 1970-01-01
      相关资源
      最近更新 更多