crosstalk
crosstalk copied to clipboard
Implement default selections
Fixes #35.
Thanks for this. Will this functionality be available soon?
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.
When selecting the correct entry, the plots get's properly updated:
I don't think this is the expected behavior when setting a selected state in the filter.
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.
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")
.
Fixes #35.
(I would LOVE some help implementing the same for
filter_checkbox
andfilter_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)
It seems that the problem I reported only happens with plotly. See @cpsievert post here: https://github.com/rstudio/crosstalk/issues/16#issuecomment-558758141
Is this feature has been updated? There is no "selected" argument in the latest CRAN update.
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.