[英]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.