crosstalk icon indicating copy to clipboard operation
crosstalk copied to clipboard

Implement default selections

Open jcheng5 opened this issue 5 years ago • 9 comments

Fixes #35.

jcheng5 avatar Jul 07 '19 00:07 jcheng5

Thanks for this. Will this functionality be available soon?

mabecker89 avatar Sep 11 '19 20:09 mabecker89

Actually, I think there is a problem with the selected state not being properly propagated on the crossdata dataset.

I installed crosslink from this branch - devtools::install_github("rstudio/crosstalk", ref = "joe/feature/filter-select-default")

Here is my demo application:

sd <- SharedData$new(cnts)
filter_select(
  id = "gene",
  label = "Select Gene",
  sharedData = sd,
  group = ~gene,
  multiple = FALSE,
  selected = cnts %>% 
    head(1) %>%
    dplyr::select(gene) %>%
    dplyr::pull()
  )

plot <- sd %>% ggplot2::ggplot(ggplot2::aes(treatment, value, group = gene)) +
  ggplot2::geom_point() +
  ggplot2::geom_boxplot()

plotly::ggplotly(plot)

Upon loading, the input has the proper entry selected, but the plot still renders the whole data set.

image

When selecting the correct entry, the plots get's properly updated:

image

I don't think this is the expected behavior when setting a selected state in the filter.

paulklemm avatar Oct 18 '19 11:10 paulklemm

I can't repro with Leaflet:

library(crosstalk)
library(leaflet)

sd <- SharedData$new(quakes)
filt <- filter_select(
  id = "mag",
  label = "Select magnitude",
  sharedData = sd,
  group = ~as.integer(mag),
  multiple = FALSE,
  selected = 5
)

map <- leaflet(sd) %>% addMarkers()

bscols(widths = c(3,9), filt, map)

@cpsievert, maybe something for us to take a quick look at together next week.

jcheng5 avatar Oct 18 '19 18:10 jcheng5

This issue is still happening for me, like @paulklemm, using ggplotly and downloading from devtools::install_github("rstudio/crosstalk", ref = "joe/feature/filter-select-default").

Nova-Scotia avatar Jan 30 '20 21:01 Nova-Scotia

Fixes #35.

(I would LOVE some help implementing the same for filter_checkbox and filter_slider.)

For filter_checkbox you can add at the end of flexdashboard assumming that "SelYear" is the id filter_checkbox(id="SelYear", label = "", sharedData = sd19, group = ~YEAR, inline = FALSE)

gtdca98 avatar Mar 27 '20 18:03 gtdca98

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 23 '20 22:04 CLAassistant

It seems that the problem I reported only happens with plotly. See @cpsievert post here: https://github.com/rstudio/crosstalk/issues/16#issuecomment-558758141

paulklemm avatar Jul 03 '20 10:07 paulklemm

Is this feature has been updated? There is no "selected" argument in the latest CRAN update.

ashishjain1988 avatar Jan 15 '21 18:01 ashishjain1988

Hi, can I ask what the status of this PR is? I've been relying in a couple of toy projects on installing the branch version that implements this change, I'd like to use it in some production code (in a non-Shiny rmarkdown project) but would prefer to use the "main" version of the package rather than a branched offshoot.

mattkerlogue avatar May 26 '22 13:05 mattkerlogue