簡體   English   中英

如何在閃亮儀表板的背景色框中顯示數據表

[英]How to show data table in a box with background color in shinydashboard

我想將我的數據表放在我的 shiny 儀表板的框中。 我將我的盒子背景顏色設置為綠色。 但是,我發現我的數據表內容沒有顯示在框中。 有誰知道如何解決這個問題? 謝謝。

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)

這只是您的字體顏色的問題:

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM