【问题标题】:Increasing the height of the DateRangeInput and alignment in R shiny增加 DateRangeInput 的高度和 R 中的对齐方式闪亮
【发布时间】:2018-01-10 10:31:01
【问题描述】:

我需要以下 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)

【问题讨论】:

  • 我已经使用 tags$style 修复了 daterangebar 的高度问题。请帮助我现在解决调整大小的问题。

标签: css r shiny shinydashboard


【解决方案1】:

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

除此之外:你有点风格的 div 对实现你想要的没有用处。随意浏览 Fluid Grid 上的 shiny layout guide 部分,探索通过使用 Shiny 提供的正确功能来进行造型的可能性。

对于日期范围小部件中的高度问题:选择的最小高度为 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)

【讨论】:

猜你喜欢
  • 2021-01-04
  • 2013-05-16
  • 2015-04-29
  • 2014-06-30
  • 2015-04-26
  • 1970-01-01
  • 2015-04-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多