旋转选择器输入隐藏下拉菜单

时间:2019-12-11 23:19:18

标签: css r shiny shinywidgets

我正在尝试旋转pickerinput,以便yaxis选择就在它旁边。

我附上两个例子:

  1. 使用shinyWidgets::pickerInput

image

  1. 使用shiny::selectInput

image

如何使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))
  })
}
)

0 个答案:

没有答案