如何解决DT :: datatable彼此重叠
我创建了一个闪亮的应用程序,该应用程序基于过滤数据构建了动态数量的DT表,但是这些表相互重叠,因此一个表底部的标题将被下一个表的列名覆盖表。我尝试寻找设置整个表的表边距的方法,但没有找到任何方法。
这是我的用户界面代码
library(shiny)
library(shinydashboard)
library(shinycssloaders)
load("scoreboard_table.R")
## Set Options for loading icon
options(spinner.color="#0c4c54",spinner.color.background="#ffffff",spinner.size=2)
ui <- dashboardPage(
skin = "blue",dashboardHeader(
title = "Scoreboard"
),dashboardSidebar(
sidebarMenu(
menuItem("Scoreboard",tabName = "scoreboard",icon = icon("dashboard")
),selectInput("league","League:",choices = unique(scoreboard_table$league),selected = "League of Legends Championship Series"),menuItem("Schedules",tabName = "schedules",icon = icon("th"))
)
),dashboardBody(
tabItems(
tabItem(tabName = "scoreboard",h2("scoreboard"),fluidRow(
uiOutput("tables")
)
),tabItem(tabName = "schedules",h2("schedules")
)
)
)
)
这是我的服务器代码
library(shiny)
library(shinydashboard)
load("scoreboard_table.R")
server <- function(input,output,session) {
## Create reactive data table that filters the data based on the league
## selected in the ui
reactive_table <- reactive({
scoreboard_table %>%
filter(league == input$league) %>%
select(-league)
})
## Create the tables of scoreboards from the reactive datatable
output$tables <- renderUI({
purrr::map(unique(reactive_table()$game),function(x){
date_time <- reactive_table() %>%
filter(game == x) %>%
slice_head(n = 1) %>%
pull(date_time)
reactive_table() %>%
filter(game == x) %>%
DT::datatable(escape = FALSE,rownames = FALSE,options = list(
pageLength = 13,dom = 't',ordering = FALSE,columnDefs = list(
list(visible = FALSE,targets = c(4:5)),list(width = '20%',targets = list(0,1,2,3))
)
),colnames = c("","Red Team","Blue Team",""),caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',htmltools::em(paste(x," - ",date_time))
)
) %>%
DT::formatStyle(
1,target = "row",fontWeight = DT::styleEqual("Top Performer","bold")
)
}
)
})
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。