簡體   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