【发布时间】:2021-11-24 01:11:47
【问题描述】:
我试图显示数据表是 R 闪亮并在语法中传递宽度参数。但是,表格没有显示为全宽。所以,我试图减少表格和输入滑块之间的差距。任何帮助表示赞赏。下面是输出的语法和图像。
#### Required Packages
Pckg_to_Inst = c("dashboardthemes", "shiny", "shinythemes",
"shinydashboard", "shinyWidgets", "DT", "bslib", "thematic", "shinydashboardPlus", "summaryBox")
##### Defining Negation
'%not_in%' = Negate('%in%')
for(i in 1:length(Pckg_to_Inst)){
if(Pckg_to_Inst[i] %not_in% installed.packages()) install.packages(Pckg_to_Inst[i],
dependencies = TRUE)
library(Pckg_to_Inst[i], character.only = TRUE)
}
#######################################################
ui <- fluidPage(
titlePanel("Dashboard"),
br(),
navbarPage("",
###### Here : insert shinydashboard dependencies ######
header = tagList(
useShinydashboard()
),
#######################################################
navbarMenu("Data Tracker", icon = icon("database"),
tabPanel("Test", fluid = TRUE,
hr(),
fluidRow(
column(12,
uiOutput("summarybox"))
),
hr(),
fluidRow(
column(8,
column(width = 12,
mainPanel(DT::dataTableOutput("table1")))),
column(4,
box(
width = 12,
title = "Data Secription - ",
selectInput(inputId = "Data_Type",
label = "Select Time Frame/Data Type",
choices = c("A", "B", "C", "D"),
selected = "A",
width = "220px"),
background = "black",
"A box with a solid black background"
)))
))
))
server <- function(input, output) {
output$table1 <- DT::renderDataTable({
DT::datatable(iris, class = 'cell-border stripe',
options = list(
initComplete = JS(
"function(settings, json) {","$(this.api().table().header()).css({'background-color': 'teal', 'color': 'black'});","}"),
scrollX = TRUE,
scrollY = TRUE,
pageLength = 5),
extensions = 'Buttons',
selection = 'single', ## enable selection of a single row
filter = 'top', ## include column filters at the bottom
)
})
}
shinyApp(ui, server)
【问题讨论】: