【问题标题】:shiny fluidrow column white space闪亮的流体行列白色空间
【发布时间】:2016-08-15 04:03:39
【问题描述】:

我有一个顶部横幅,我想将其分成两个单独的部分,代表两个不同的输入。为此,我创建了一个fluidRow 和两列,每个输入一个列。但是,尽管设置了 offset = 0,但现在列之间有一点空白。有没有办法删除这个空白,使列立即彼此相邻?

colors = c("green","blue","red")
library(shiny)

ui <- fluidPage(

  tabsetPanel(
    tabPanel("Info",
             fluidRow( 
                   column(width = 6, offset = 0,
                      div(style = "height:50px;width:100%;background-color: #999999;border-style: solid;border-color: #000000",
                          tags$h3("Section 1")
                      )
                   ),
                   column(width = 6, offset = 0,
                       div(style = "height:50px;width:100%;background-color: #999999;border-style: solid;border-color: #000000",       
                          tags$h3("Section 2")
                       )
                   ) 
             ),
             fluidRow(
                   column(width = 6, offset = 0,
                   div(style = "height:50px;width:100%;background-color: #999999;border-style: solid;border-color: #000000",       
                       selectInput(inputId = "color",label = "color:",
                                   choices = colors,
                                   selected = colors[2],
                                   multiple = FALSE)
                      )
                    ),
                   column(width = 6, offset = 0,
                          div(style = "height:50px;width:100%;background-color: #999999;border-style: solid;border-color: #000000",       
                              selectInput(inputId = "points",label = "Number of Points:",
                                          choices = c("30","60","90"),
                                          selected = "10",
                                          multiple = FALSE)                      )
                   )
             ),   
             br(),
             br(),
             fluidRow(
                   actionButton(inputId = "go",
                                label = "Update"
                   )
             ),
             fluidRow(
                   plotOutput("plot", width = "100%")
             )

    )
  )
)


server <- function(input, output,session) {

  data = eventReactive(input$go, {
    var1 = rnorm(isolate(as.numeric(input$points)),5)
    cat1 = c(rep("red",length(var1)/3),rep("blue",length(var1)/3),rep("green",length(var1)/3))
    data = cbind.data.frame(var1,cat1)
    plotdata = data[which(data$cat1 ==isolate(input$color)),] 
  }
  )

  output$plot = renderPlot({
    plotdata = data()
    plotcol = isolate(input$color)
    plot(plotdata$var1, col = plotcol) 
  })
}

shinyApp(ui = ui,server = server)

【问题讨论】:

    标签: r shiny whitespace


    【解决方案1】:

    空格是div 列的填充。要删除它,请使用

    column(width = 6, offset = 0, style='padding:0px;', ...)
    

    【讨论】:

    • 对于那些可能与我遇到相同问题的人来说,这是一个小补充:如果您想单独更改左、右、上和下的填充,这可以通过非常类似的直接方式实现:column(width = 6, offset = 0, style='padding-left:0px; padding-right:1px; padding-top:5px; padding-bottom:5px', ...)
    猜你喜欢
    • 2021-09-26
    • 1970-01-01
    • 2017-02-15
    • 2020-08-30
    • 2016-06-09
    • 2019-06-08
    • 2021-09-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多