【问题标题】:The select drop down menu appear behind other elements in shiny选择下拉菜单出现在闪亮的其他元素后面
【发布时间】:2018-02-22 03:53:03
【问题描述】:

任何人都可以给我一个解决方案来解决以下问题,即当要选择下拉菜单中的第一个项目时,下拉菜单会在情节悬停下。

我使用了以下代码。但是没用。

在用户界面中,

fluidRow(
                                   tags$hr(style="z-index: 10000;"),
                                   column(width = 3,h2("Device Type")),
                                   column(width = 3,htmlOutput("disselect")),
                                   column(width = 3,htmlOutput("cityeselect")),
                                   column(width = 3,h2("Property Type"))
                                 ),

在服务器中

output$disselect <- renderUI({
    selectInput("district", "District", c("All",unique(bookings$District)), selected = "All")
  })

有什么技巧吗?

【问题讨论】:

    标签: javascript r shiny


    【解决方案1】:

    设置下拉菜单的 z-index 使其大于绘图模式栏的 z-index,例如 1002 会起作用:

    column(width = 3, offset = 9, 
                   selectInput("y", "y", colnames(mtcars)),style="z-index:1002;")
    

    一个工作示例:

    library(shiny)
    library(plotly)
    
    ui <- fluidPage(
      fluidRow(
        column(width = 3, offset = 9, 
               selectInput("y", "y", colnames(mtcars)),style="z-index:1002;")
      ),
      fluidRow(plotlyOutput("plot"))
    )
    
    server <- function(input, output, session) {
      output$plot <- renderPlotly({
        g <- ggplot(mtcars, aes_string("disp", input$y)) +
          geom_point()
        g <- ggplotly(g) %>%
          config(displayModeBar = TRUE)
        g
      })
    }
    
    shinyApp(ui, server) 
    

    【讨论】:

      【解决方案2】:

      如果您不需要plotly modebar,则只需remove it

      这是一个例子:

      library(shiny)
      library(plotly)
      
      ui <- fluidPage(
              fluidRow(
                      column(width = 3, offset = 9, 
                             selectInput("y", "y", colnames(mtcars)))
              ),
              fluidRow(plotlyOutput("plot"))
      )
      
      server <- function(input, output, session) {
              output$plot <- renderPlotly({
                      g <- ggplot(mtcars, aes_string("disp", input$y)) +
                              geom_point()
                      ### code to hide the modebar ###
                      g <- ggplotly(g) %>%
                              config(displayModeBar = FALSE)
                      g
              })
      }
      
      shinyApp(ui, server)
      

      【讨论】:

        猜你喜欢
        • 2018-09-04
        • 2013-04-15
        • 1970-01-01
        • 1970-01-01
        • 2015-12-08
        • 2011-04-27
        • 2014-10-05
        • 2012-10-20
        • 1970-01-01
        相关资源
        最近更新 更多