Display DT table below when user hovers any data point on the graph

Hi all,

Can we display a DT table below the plot when the mouse hovers over any data point. Basically the DT table should display only the point where the hovering is happening


ui <- fluidPage(

server <- function(input, output, session) {
  output$lchart <- renderPlotly({
    plot_ly(iris) %>% 
      layout(yaxis = list(title = "Total")) %>%
      add_trace(x = ~Sepal.Width, y = ~Petal.Width, type='scatter', yaxis = "y1", color = I("#3090C7"),name = 'Plot') 

shinyApp(ui, server)

1 Like

@vinayprakash808, the key is using event_data() of type plotly_hover; these keep track of where the user hovers (returns the data row id), which one may then use on shiny server-side to filter the data for DT display.

Here are 2 useful resources:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.