rstudio / crosstalk

Inter-htmlwidget communication for R (with and without Shiny)
http://rstudio.github.io/crosstalk
Other
290 stars 53 forks source link

multiple filter_select with subsetting choices #149

Open micboat opened 5 months ago

micboat commented 5 months ago

Hi

Am not sure how to ensure that muni_filter shows only "A" to "E" as choice to select from after selecting "North" in region_filter. Is that possible with crosstalk. Here is my example in R,

Sample data

df <- data.frame( region = rep(c("North", "South", "East", "West"), each = 5), muni = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T"), value = runif(20, 10, 100) )

Create shared data objects

sd <- SharedData$new(df, key = ~muni, group = "shared_group")

Region filter

region_filter <- filter_select( id = "region", label = "Select Region:", sharedData = sd, group = ~region, multiple = FALSE )

Municipality filter

muni_filter <- filter_select( id = "muni", label = "Select Municipality:", sharedData = sd, group = ~muni, multiple = FALSE )

Arrange the filters in a column layout

filter_panel <- bscols( widths = c(4, 4), region_filter, muni_filter )