如何将独立的单选按钮组放在同一行上,并在组周围放置井面板以描绘它们?
How to place independent groups of radio buttons on same row and place well panels around the groups in order to delineate them?
我试图将 2 个独立的单选按钮组放在同一行上,对齐并用孔板(或框)分隔这 2 个组,首先,以便更好地为用户描绘它们并明确表示它们没有链接。
下面是我尝试将单选按钮组放在同一行的 MWE。我尝试 fluidRow()
里面有列,但还没有成功。这些按钮不起作用,因为这是精简的 MWE。我在条件面板、主面板、选项卡等中留下了一些基本内容,以防这些格式对我尝试做的事情产生影响。
下面的第一张图片显示了 运行 MWE 时出现的内容,第二张图片显示了我正在尝试执行的操作。
请注意,实际数据 table 这远远向右延伸了 40 列,所以我不担心单选按钮适合一行(无需换行)。
MWE:
library(dplyr)
library(DT)
library(shiny)
library(shinyWidgets)
ui <-
fluidPage(
titlePanel("Summary"),
sidebarLayout(
sidebarPanel(
selectInput("selectData", h5(strong("Select data to view:")),
choices = list("Beta"),
selected = "Beta"),
),
mainPanel(
tabsetPanel(
tabPanel("Private data", value = 1,
conditionalPanel(condition = "input.selectData == 'Beta'",
fluidRow(div(style = "margin-top:15px"),
column(width = 12, offset = 0, style='padding-right:0px;',
radioButtons(inputId = 'group1',
label = NULL,
choiceNames = c('By period','By MOA'),
choiceValues = c('Period','MOA'),
selected = 'Period',
inline = TRUE
)
),
column(width = 12, offset = 0, style='padding-right:0px;',
radioButtons(inputId = 'group2',
label = NULL,
choiceNames = c('Exclude CT','Include CT'),
choiceValues = c('Exclude','Include'),
selected = 'Exclude',
inline = TRUE
)
)
),
DTOutput("plants")
)
),
id = "tabselected"
)
)
)
)
server <- function(input, output, session) {
output$plants <- renderDT({iris %>% datatable(rownames = FALSE)})
}
shinyApp(ui, server)
问题是
Column widths are based on the Bootstrap 12-wide grid system, so should add up to 12 within a fluidRow() container.
由于您已将每列的最大宽度设置为 12,因此它们将被放置在不同的行中。要解决此问题,请将列宽减小到 6。
为了让您的井面板将 radioButton
包裹在 wellPanel
中:
library(shiny)
library(shinyWidgets)
ui <-
fluidPage(
titlePanel("Summary"),
sidebarLayout(
sidebarPanel(
selectInput("selectData", h5(strong("Select data to view:")),
choices = list("Beta"),
selected = "Beta"
),
),
mainPanel(
tabsetPanel(
tabPanel("Private data",
value = 1,
conditionalPanel(
condition = "input.selectData == 'Beta'",
fluidRow(
div(style = "margin-top:15px"),
column(
width = 6, offset = 0, style = "padding-right:0px;",
wellPanel(
radioButtons(
inputId = "group1",
label = NULL,
choiceNames = c("By period", "By MOA"),
choiceValues = c("Period", "MOA"),
selected = "Period",
inline = TRUE
)
)
),
column(
width = 6, offset = 0, style = "padding-right:0px;",
wellPanel(
radioButtons(
inputId = "group2",
label = NULL,
choiceNames = c("Exclude CT", "Include CT"),
choiceValues = c("Exclude", "Include"),
selected = "Exclude",
inline = TRUE
)
)
)
)
)
),
id = "tabselected"
)
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
我试图将 2 个独立的单选按钮组放在同一行上,对齐并用孔板(或框)分隔这 2 个组,首先,以便更好地为用户描绘它们并明确表示它们没有链接。
下面是我尝试将单选按钮组放在同一行的 MWE。我尝试 fluidRow()
里面有列,但还没有成功。这些按钮不起作用,因为这是精简的 MWE。我在条件面板、主面板、选项卡等中留下了一些基本内容,以防这些格式对我尝试做的事情产生影响。
下面的第一张图片显示了 运行 MWE 时出现的内容,第二张图片显示了我正在尝试执行的操作。
请注意,实际数据 table 这远远向右延伸了 40 列,所以我不担心单选按钮适合一行(无需换行)。
MWE:
library(dplyr)
library(DT)
library(shiny)
library(shinyWidgets)
ui <-
fluidPage(
titlePanel("Summary"),
sidebarLayout(
sidebarPanel(
selectInput("selectData", h5(strong("Select data to view:")),
choices = list("Beta"),
selected = "Beta"),
),
mainPanel(
tabsetPanel(
tabPanel("Private data", value = 1,
conditionalPanel(condition = "input.selectData == 'Beta'",
fluidRow(div(style = "margin-top:15px"),
column(width = 12, offset = 0, style='padding-right:0px;',
radioButtons(inputId = 'group1',
label = NULL,
choiceNames = c('By period','By MOA'),
choiceValues = c('Period','MOA'),
selected = 'Period',
inline = TRUE
)
),
column(width = 12, offset = 0, style='padding-right:0px;',
radioButtons(inputId = 'group2',
label = NULL,
choiceNames = c('Exclude CT','Include CT'),
choiceValues = c('Exclude','Include'),
selected = 'Exclude',
inline = TRUE
)
)
),
DTOutput("plants")
)
),
id = "tabselected"
)
)
)
)
server <- function(input, output, session) {
output$plants <- renderDT({iris %>% datatable(rownames = FALSE)})
}
shinyApp(ui, server)
问题是
Column widths are based on the Bootstrap 12-wide grid system, so should add up to 12 within a fluidRow() container.
由于您已将每列的最大宽度设置为 12,因此它们将被放置在不同的行中。要解决此问题,请将列宽减小到 6。
为了让您的井面板将 radioButton
包裹在 wellPanel
中:
library(shiny)
library(shinyWidgets)
ui <-
fluidPage(
titlePanel("Summary"),
sidebarLayout(
sidebarPanel(
selectInput("selectData", h5(strong("Select data to view:")),
choices = list("Beta"),
selected = "Beta"
),
),
mainPanel(
tabsetPanel(
tabPanel("Private data",
value = 1,
conditionalPanel(
condition = "input.selectData == 'Beta'",
fluidRow(
div(style = "margin-top:15px"),
column(
width = 6, offset = 0, style = "padding-right:0px;",
wellPanel(
radioButtons(
inputId = "group1",
label = NULL,
choiceNames = c("By period", "By MOA"),
choiceValues = c("Period", "MOA"),
selected = "Period",
inline = TRUE
)
)
),
column(
width = 6, offset = 0, style = "padding-right:0px;",
wellPanel(
radioButtons(
inputId = "group2",
label = NULL,
choiceNames = c("Exclude CT", "Include CT"),
choiceValues = c("Exclude", "Include"),
selected = "Exclude",
inline = TRUE
)
)
)
)
)
),
id = "tabselected"
)
)
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)