繁体   English   中英

选择下拉菜单出现在其他元素的后面

[英]The select drop down menu appear behind other elements in shiny

任何人都可以给我一个以下问题的解决方案:在下拉菜单中选择拳头项时,下拉菜单会悬停在悬停的悬停下方。

在此处输入图片说明

我用下面的代码。 但是没有用。

在用户界面中

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")
  })

有骇客吗?

设置下拉菜单的z-index,使其大于plotly模式栏的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) 

如果您不需要plotly modebar ,您可以删除它

这是一个例子:

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)

例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM