改变Shiny中的井板高度

时间:2014-12-19 19:23:38

标签: r shiny

我的Shiny viz顶部有一个很好的wellpanel看起来不错:

screenshot

...但我对实际控件上方和下方的所有额外灰色空间感到恼火!我想删除这个不必要的空间。我的行比它需要的高50%,并且我不确定为什么/如何以这种方式调整它的大小。

有没有css / html / Shiny技能的人是否能够指出我正确的方向,关于如何修改它?到目前为止,我的尝试都没有成功。

以下是代码:

shinyUI(fluidPage(


  fluidRow(  
    column(12,
           wellPanel(              
             tags$div(class = "row",
                      tags$div(class = "span"),
                      tags$div(class = "span1", h1(numericInput(inputId="num", label="ID", value=NaN))),
                      tags$div(class = "span2", h1(sliderInput(inputId="age", "Age Range", min=32, max=99, value=c(32, 99), step=1))),
                      tags$div(class = "span1", h1(radioButtons(inputId="gender", "Gender", c("combined" = 0, "male" = 1, "female" = 2), inline=FALSE))),
                      tags$div(class = "span1", h1(textOutput("text")))
             )
           ))),  



  fluidRow(   


    column(4,
           plotOutput("some_plot_not_shown"))

)))

感谢您阅读此内容。

2 个答案:

答案 0 :(得分:8)

您可以更改填充:

library(shiny)
runApp(
  list(ui = fluidPage(           
    wellPanel(              
    tags$div(class = "row",
             tags$div(class = "span"),
             tags$div(class = "span1", h1(numericInput(inputId="num", label="ID", value=NaN))),
             tags$div(class = "span2", h1(sliderInput(inputId="age", "Age Range", min=32, max=99, value=c(32, 99), step=1))),
             tags$div(class = "span1", h1(radioButtons(inputId="gender", "Gender", c("combined" = 0, "male" = 1, "female" = 2), inline=FALSE))),
             tags$div(class = "span1", h1(textOutput("text")))
    )
  , style = "padding: 5px;")
  , wellPanel(              
    tags$div(class = "row",
             tags$div(class = "span"),
             tags$div(class = "span1", h1(numericInput(inputId="num1", label="ID", value=NaN))),
             tags$div(class = "span2", h1(sliderInput(inputId="age1", "Age Range", min=32, max=99, value=c(32, 99), step=1))),
             tags$div(class = "span1", h1(radioButtons(inputId="gender1", "Gender", c("combined" = 0, "male" = 1, "female" = 2), inline=FALSE))),
             tags$div(class = "span1", h1(textOutput("text1")))
    )
    , style = "padding: 45px;")
  )
       , server = function(input, output, session){

       }
       )
  )

enter image description here

答案 1 :(得分:2)

我认为您在添加spans时尝试使用columns确实是您所追求的 - 试试这个:

shinyUI(fluidPage(
  fluidRow(
    column(12,
      fluidRow(
        wellPanel(
          fluidRow(
            column(3, h1(numericInput(inputId="num", label="ID", value=NaN))),
            column(3, h1(sliderInput(inputId="age", "Age Range", min=32, max=99, value=c(32, 99), step=1))),
            column(3, h1(radioButtons(inputId="gender", "Gender", c("combined" = 0, "male" = 1, "female" = 2), inline=FALSE))),
            column(3, h1(textOutput("text")))
          )
        ) # End wellPanel
      )
    )
  ),
  fluidRow(
    column(4, plotOutput("some_plot_not_shown"))
  )
))

Shiny