Plotly Interaction with DataTable in R Crosstalk

414 Views Asked by At

I am creating a flexdashboard (not shiny and knitted through markdown to create a static HTML) backed by the SharedData in the crosstalk package. I have two types of data: data_wide used in the datatable that shows information about the key variable and data_long used in the plotly graph that will show a line graph of score for each year for each key variable.

However, my datatable and plotly graph does not seem to be interacting. In other words, when I select a row in the datatable, the plotly graph does not seem to highlight the line that represents that key.

Here is a mock code:

data_wide <- SharedData$new(data_wide, key = ~key)
data_long <- SharedData$new(data_long, key = ~key)

data_long %>% 
  plot_ly(x = ~year, y = ~score, split = ~key, color = ~key, type = "scatter", mode = "lines") %>% 
  highlight()

wide_data  %>% 
  datatable(style="bootstrap", class="compact", width="100%", rownames = F, escape = F, 
    options=list(deferRender=TRUE, scrollX = T))
0

There are 0 best solutions below