简体   繁体   English

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

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

I need the following requirement with the R script below. 我需要以下R脚本满足以下要求。 When you click on the sidebar symbol at the top, when dashboard body expands, all widgets are in one line, however when the dashboard body shrinks, the dateRangeInput widget appears in the below line. 当单击顶部的侧边栏符号时,当仪表板主体展开时,所有窗口小部件都在一行中,但是当仪表板主体收缩时, dateRangeInput窗口小部件将出现在下一行中。 I want all widgets to appear in one line and resize accordingly. 我希望所有小部件都显示在一行中,并相应地调整大小。 Please help and thanks. 请帮忙,谢谢。

## 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)

快照捕捉

Some of your code was off such that one didnt even see the box around your inputs. 您的某些代码已关闭,以至于您甚至看不到输入周围的框。

Besides that: You're somewhat styled divs were not useful in achieving what you desired. 除此之外,您的div样式对于实现所需的效果没有用。 Feel free to browse through the shiny layout guide section on the Fluid Grid to explore what possibilities in styling you have by just using the right functions shiny offers. 随意浏览Fluid Grid闪亮的布局指南部分,仅使用闪亮的功能即可探索样式的可能性。

For the height issue in daterange widgets: The selects have a min-height of 34 pixels. 对于日期范围小部件中的高度问题:选择的最小高度为34像素。 If you also apply that to daterange objects by css, you can have them be the same size. 如果还通过CSS将其应用于daterange对象,则可以使它们具有相同的大小。

Corrected code below: 更正了以下代码:

## 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