R语言 如何创建一个可滚动的井面板,而不受光泽网格布局系统的约束?

xpszyzbs  于 2023-04-03  发布在  其他
关注(0)|答案(1)|浏览(87)

在底部的示例代码中,我使用wellPanel()来处理六个用户输入。我试图将用户输入扩展到wellPanel()的右侧,如下图所示,使用滑动控件让用户在wellPanel()中向右移动,以显示额外的输入部件。我目前使用的是标准的Shiny网格布局,其中所有列宽的最大值被限制为12,这是我所知道的唯一一种将输入小部件整齐地排列成行/列的方法。是否有一种方法可以在wellPanel()的右侧添加额外的列,同时保持当前的输入小部件宽度,用户向右滚动以查看这些附加输入?我并不拘泥于网格布局系统,如果有其他方法可以整齐地将Shiny输入小部件排列成行/列。目前六个输入小部件的布局是整洁的,尽管有限制。

验证码:

library(shiny)

ui <- fluidPage(
  br(),
  wellPanel(id = "tPanel",style = "overflow-x:scroll",
    fluidRow(
      column(5,
          selectInput("viewType","View options:",c("plot")),
          numericInput("winStart","Start month of study:",value = 0, max = 15, min = 0),
          selectInput("uniCov", "Single-predictor for KM:",c("None" = 1))
      ),
      column(5,
          selectInput("curveType","View survival plot:",c("Survival" = "pct")),
          numericInput("winEnd","End month of study:", value = 40, max = 40, min = 20),
          selectizeInput("multiCov", "Multi-predictors for Cox:",c("Node" = "Node"))
      )
    )
  ),
  h4("Plots go here...")
)

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

shinyApp(ui, server)
y1aodyip

y1aodyip1#

使用splitLayout的方法:

library(shiny)

ui <- fluidPage(
  br(), br(),
  wellPanel(
    style = "overflow-x: scroll",
    splitLayout(
      # first column
      column(
        12,
        numericInput("i1", "I1", 1)
      ),
      # second column
      column(
        12,
        numericInput("i2", "I2", 2)
      ),
      # third column
      column(
        12,
        numericInput("i3", "I3", 3)
      ),
      # column widths
      cellWidths = "40%"
    )
  )
)

server <- function(input, output) {}

shinyApp(ui, server)

相关问题