我正在尝试旋转选择器输入,以便 yaxis 选择就在它旁边。
我附上两个例子:
- 使用
shinyWidgets::pickerInput
- 使用
shiny::selectInput
如何使pickerinput下拉菜单不隐藏在绘图后面或看起来像selectinput的下拉菜单?
代码示例 1:
library(shiny)
library(shinyWidgets)
library(tidyverse)
shiny::shinyApp(
ui = fluidPage(
# Application title
titlePanel("Rotating Picker Input"),
# Sidebar with a slider input for number of bins
# Show a plot of the generated distribution
fluidRow(
column(
2,
fluidRow(
style = "transform: rotate(270deg) translateX(-150px) translateY(-50px); width: 350px; ",
shinyWidgets::pickerInput(
inputId = "select_y",
label = "Select Y",
choices = colnames(mtcars),
selected = colnames(mtcars)[1],
options = list(
`actions-box` = TRUE,
`selected-text-format` = "count > 2"
),
multiple = FALSE
)
)
),
column(
10,
plotOutput("distPlot"),
pickerInput(
inputId = "select_x",
label = "Select X",
choices = colnames(mtcars),
selected = colnames(mtcars)[1],
options = list(
`actions-box` = TRUE,
`selected-text-format` = "count > 2"
),
multiple = FALSE
)
)
)
),
# Define server logic required to draw a histogram
server = function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
ggplot(data = mtcars) + geom_point(aes_string(x = input$select_x, y = input$select_y))
})
}
)
代码示例 2:
library(shiny)
library(shinyWidgets)
library(tidyverse)
shiny::shinyApp(
ui = fluidPage(
# Application title
titlePanel("Rotating Picker Input"),
# Sidebar with a slider input for number of bins
# Show a plot of the generated distribution
fluidRow(
column(
2,
fluidRow(
style = "transform: rotate(270deg) translateX(-150px) translateY(-50px); width: 350px; ",
shiny::selectInput(
inputId = "select_y",
label = "Select Y",
choices = colnames(mtcars),
selected = colnames(mtcars)[1],
selectize = FALSE
)
)
),
column(
10,
plotOutput("distPlot"),
pickerInput(
inputId = "select_x",
label = "Select X",
choices = colnames(mtcars),
selected = colnames(mtcars)[1],
options = list(
`actions-box` = TRUE,
`selected-text-format` = "count > 2"
),
multiple = FALSE
)
)
)
),
# Define server logic required to draw a histogram
server = function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
ggplot(data = mtcars) + geom_point(aes_string(x = input$select_x, y = input$select_y))
})
}
)