繁体   English   中英

增加DateRangeInput的高度并在R Shiny中对齐

[英]Increasing the height of the DateRangeInput and alignment in R shiny

我需要以下R脚本满足以下要求。 当单击顶部的侧边栏符号时,当仪表板主体展开时,所有窗口小部件都在一行中,但是当仪表板主体收缩时, dateRangeInput窗口小部件将出现在下一行中。 我希望所有小部件都显示在一行中,并相应地调整大小。 请帮忙,谢谢。

## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(title = "Data", fluidPage(

  div(style = "display: inline-block;vertical-align:top; width: 600 px;", 
selectInput("select1","select1",c("A1","A2","A3")),selected = "A1"),
  div(style = "display: inline-block;vertical-align:top; width: 600 px;", 
selectInput("select2","select2",c("A3","A4","A5")),selected = "A3"),
  div(style = "display: inline-block;vertical-align:top; width: 600 px;", 
selectInput("select2","select2",c("A3","A4","A5")),selected = "A3"),
  div(style = "display: inline-block;vertical-align:top; width: 600 px;", 
selectInput("select2","select2",c("A3","A4","A5")),selected = "A3"),
div(style = "display: inline-block;vertical-align:top; width: 600 px;",   
dateRangeInput("daterange1", "Date range:",

start = "2001-01-01",

end   = "2010-12-31")
),
status = "primary", solidHeader = T, width = 12, height = 120)
)
))
server <- function(input, output) { }
shinyApp(ui, server)

快照捕捉

您的某些代码已关闭,以至于您甚至看不到输入周围的框。

除此之外,您的div样式对于实现所需的效果没有用。 随意浏览Fluid Grid闪亮的布局指南部分,仅使用闪亮的功能即可探索样式的可能性。

对于日期范围小部件中的高度问题:选择的最小高度为34像素。 如果还通过CSS将其应用于daterange对象,则可以使它们具有相同的大小。

更正了以下代码:

## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    box(title = "Data", status = "primary", solidHeader = T, width = 12,
      fluidPage(
        fluidRow(
          column(2, selectInput("select1","select1",c("A1","A2","A3"), selected = "A1")),
          column(2, selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")),
          column(2, selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")),
          column(2, selectInput("select2","select2",c("A3","A4","A5"), selected = "A3")),
          column(4, dateRangeInput("daterange1", "Date range:", start = "2001-01-01",end = "2010-12-31")),
          tags$head(
            tags$style("
              .input-daterange input {
                min-height: 34px;
              }
            ")
          )
        )
      )
    )
  )
)
server <- function(input, output) { }
shinyApp(ui, server)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM