2

I have a plotly heatplot, which on hover triggers the plotting of another line chart. This is fairly time-intensive. This is why I would like to trigger the hover event only if the hover took longer than 2 seconds. Is there a way to do this in shiny/plotly ?

Here's the hover event:

output$distPlot <- renderPlot({
event_data <- event_data("plotly_hover", source = "heatplot")
if (length(event_data)) {
  selectedDate <- event_data[["y"]]
  #draw Plot
  ggplot(myData[date==selectedDate], aes(y=y, x=x)) + geom_line()
}
})
Cos
  • 1,649
  • 1
  • 27
  • 50
  • why do you use the hover event? why not the select event? The latter seems easier to me – 5th Jun 05 '18 at 12:12
  • The select event has other (more important) functionality. The plot I'm triggering via hover is just an additional information for the user. – Cos Jun 05 '18 at 12:21
  • 1
    that explains stuff :D maybe you you can delay the reaction? like, e.g. here: https://stackoverflow.com/questions/1174799/how-to-make-execution-pause-sleep-wait-for-x-seconds-in-r – 5th Jun 05 '18 at 12:35
  • 1
    I tried Sys.sleep(x), but sadly it seems to delay all other functions in shiny as well – Cos Jun 05 '18 at 12:55

0 Answers0