如何在闪亮仪表板中的背景颜色框中显示数据表

问题描述 投票:0回答:1

我想将数据表放在闪亮的仪表板中的框中。我将框背景色设置为绿色。但是,我发现我的数据表内容未显示在框中。有人知道如何解决此问题吗?谢谢。

library(shiny)
library(shinydashboard)


ui <- dashboardPage(
    dashboardHeader(title = "example"),
    dashboardSidebar(),
    dashboardBody(
        box(width=6, background = 'green',
            DT::dataTableOutput('table') 
        )
    )
)

server <- function(input, output, session) {

    output$table <- DT::renderDataTable({
        DT::datatable(iris)
    })
}    


shinyApp(ui, server)
r shiny shinydashboard
1个回答
0
投票

仅取决于您的字体颜色:

library(shiny)
library(shinydashboard)


ui <- dashboardPage(
  dashboardHeader(title = "example"),
  dashboardSidebar(),
  dashboardBody(
    box(width=6, background = 'green',
        DT::dataTableOutput('table') 
    )
  )
)

server <- function(input, output, session) {

  output$table <- DT::renderDataTable({
    df <- iris
    DT::datatable(df) %>% 
      # rowid is a column as well, therefore zero to nrow()
      DT::formatStyle(0:nrow(df), color = "black")
  })
}    


shinyApp(ui, server)
© www.soinside.com 2019 - 2024. All rights reserved.