1

I am trying to use crosstalk to filter a plotly chart. I use crosstalk's filter_select to (un)filter a plotly chart. When using the reprex below trying to select a flower (e.g. setosa), all works fine. But when I unselect the flower, the values are not 'returned' to the plotly chart. Selecting '(All)' does not seem to be working either. The values reappear only when deselecting from flower filter AND ticking TRUE in the helper_select_all.

library(crosstalk)
library(plotly)

df <- iris
df$helper_select_all <- T

shared_data <- SharedData$new(df)

filter <- bscols(
  list(
    filter_select("flower", "Select a flower", shared_data, ~Species),
    filter_checkbox(
      "helper_select_all",
      label = "Reset filtering as deselecting from 'Select a flower' is not working",
      shared_data, ~helper_select_all)
  )
)


p <- plot_ly(shared_data, x = ~Sepal.Length, y = ~Sepal.Width) %>% 
  add_markers()


bscols(filter, p)

This picture demonstrates the issue as no filtering value is selected, but a part of the data is missing. enter image description here

This picture shows what it looks like when all datapoints are present. enter image description here

"(All)" does not seem to be working either. enter image description here

Jakub.Novotny
  • 2,912
  • 2
  • 6
  • 21
  • If you want to remove the "(All)" selection, install version 1.1.1 of `crosstalk`. Your graph will default to plotting all points, but you can then switch between selections appropriately. – Daniel L Apr 05 '22 at 20:57
  • @DanielL I tried to install a newer version of crosstalk, but it does not seem to be working. When I select "(All)", not all points are actually selected. – Jakub.Novotny Apr 05 '22 at 21:09
  • The newer version of `crosstalk` (1.2.0) also has (All) option, seems that specifically 1.1.1 doesn't. – tosdanielle Apr 09 '22 at 09:15
  • @tosdanielle I don’t have any problem with having “(All)” present as part of the filter. My problem is that the selecting “(All)” does NOT select all data. – Jakub.Novotny Apr 09 '22 at 09:18
  • @Jakub.Novotny I loaded version 1.2.0 of `crosstalk` and can confirm the "(All)" selection does not select anything. I'd suggest installing version 1.1.1 of `crosstalk` and setting the multiple argument to TRUE, `filter_select("flower", "Select a flower", shared_data, ~Species, multiple = T)`. To install version 1.1.1, `remotes::install_version("crosstalk", version = "1.1.1", repos = "http://cran.us.r-project.org")` then load. It is not a perfect solution but probably the best option. – Daniel L Apr 14 '22 at 01:11
  • For those interested [here](https://github.com/rstudio/crosstalk/issues/125) you can find the related GitHub issue. – ismirsehregal Apr 14 '22 at 10:06

0 Answers0