rstudio / rstudio/shiny

Bug with hoverOpts, clip=TRUE

Open
#1,982 2 comments 0 reactions 1 assignee View on GitHub

@tmastny is already working on this.

Since Jun 14, 2018.

Difficulty: Novice Effort: Low Priority: Low Type: Bug :bug:
Dominant language
R
Stars
5.7k
Forks
1.9k
Avg merge
3d 1h
Merged PRs (30d)
2

Description

I’m having some trouble getting the clip=FALSE argument to have any effect on the hover for a plot. As soon as the cursor leaves the plotting area, but is still within the plot image, the hover input goes to NULL, whether or not clip is set to TRUE or FALSE. I’ve attached a reproducible example and an online version from shinyapps.io. (This issue also seems to be the same for clickOpts)

app.R:

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

   # Application title
   titlePanel("Old Faithful Geyser Data"),
   
   # Sidebar with a slider input for number of bins 
   sidebarLayout(
      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30),
         textOutput("hoverText")
      ),
      
      # Show a plot of the generated distribution
      mainPanel(
         plotOutput("distPlot",hover=hoverOpts("dist_hover",nullOutside=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
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x), length.out = input$bins + 1)
      
      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })
   
   output$hoverText <- renderText({
     print(input$dist_hover)
     paste0("x: ",input$dist_hover$x,"y: ",input$dist_hover$y)
   })
}

# Run the application 
shinyApp(ui = ui, server = server)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.