给定的R光泽脚本会生成一个带有多个selectInput的框面板,如下面的快照所示。盒子面板是这样的,当我们隐藏或呈现侧边栏时,面板调整盒子的大小并且它们保持完整。
但是,当我删除或添加一个额外的小部件(如selectinput)时,小部件不会跨越框面板的长度端到端并突破面板。如何使得当我添加额外的小部件或删除一个小部件时,端到端跨越得到维护?
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(title = "Data", status = "primary", solidHeader = T, width = 12,
fluidPage(
fluidRow(
column(2,offset = 0, style='padding:1px;',
selectInput("select1","select1",c("A1","A2","A3"), selected = "A1")),
column(2,offset = 0, style='padding:1px;',
selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")),
column(2, offset = 0,
style='padding:1px;',selectInput("select2","select2",c("A3","A4","A5"),
selected = "A3")),
column(2, offset = 0,
style='padding:1px;',selectInput("select2","select2",c("A3","A4","A5"),
selected = "A3")),
column(2, offset = 0,
style='padding:1px;',selectInput("select2","select2",c("A3","A4","A5"),
selected = "A3")),
column(2, offset = 0,
style='padding:1px;',selectInput("select2","select2",c("A3","A4","A5"),
selected = "A3")),
tags$head(
tags$style("
.input-sm,.selectize-input {
min-height: 34px; font-size: 11.2px;
}
")))))))
server <- function(input, output) { }
shinyApp(ui, server)
答案 0 :(得分:3)
使用splitLayout
你可以试试这个。只需取消注释即可在框中添加所有六个sliderInput
。
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(title = "Data", status = "primary", solidHeader = T, width = 12,
splitLayout(
cellArgs = list(style = "padding: 10px"),
selectInput("select1","select1",c("A1","A2","A3"), selected = "A1"),
selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")
# selectInput("select2","select2",c("A3","A4","A5"), selected = "A3"),
# selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")
# selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")
# selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")
))))
server <- function(input, output) { }
shinyApp(ui, server)