Comments (6)
Wanted to bump this, is there currently a way to get a select_filter
's choices to depend on another select_filter
? in pseudocode
dessert_df = data.frame(
rating = c(1,2,3,4),
dessert_type = c("Candy", "Pie", "Candy", "Pie"),
dessert_subtype = c("KitKat", "Lemon", "Snickerdoodle", "Pecan")
)
dessert_sd = SharedData$new(dessert_df)
dessert_types_ft = filter_select("dessert_type", "Dessert Type",
dessert_sd, ~dessert_type)
dessert_subtypes_ft = filter_select("dessert_subtypes", "Dessert Subtypes",
dessert_sd, ~dessert_subtype)
Where dessert_subtypes_ft
's choices will depend on the dessert_type_ft
choice?
Edit: I'd like to not have to have shiny as a dependency
from crosstalk.
Sorry, I don't understand. The two events in Crosstalk are that someone made a selection or that someone changed a filterhandle. Which of those events do you mean by "updating of items"? Neither of those seem to me like they'd affect a filter_select
, as it isn't affected by selection nor by other filterhandles.
from crosstalk.
The two events in Crosstalk are that someone made a selection or that someone changed a filterhandle.
I get that, but it seems as though you are tying a "selection" events to direct manipulation of graphical objects, and "filter" to indirect manipulation. I think of it more generally -- either event should be able to be triggered via direct or indirect manipulation. IMO, this is especially important for selection events (if you're curious why, see this short explanation), which is why I implemented a selectize widget that responds to a crosstalk selection event (i.e., the selectize items are updated upon a selection event). Notice the bidirectional communication between the widget and the plot in this gif:
Which of those events do you mean by "updating of items"?
Both...for the reasons I layout above, I would like to see crosstalk widgets update their value when a relevant event is triggered (regardless of how they are triggered). I would also like to see crosstalk widgets that can trigger selection events (e.g., select_checkbox()
, which would be just like filter_checkbox()
, except triggers a selection event, rather than a filter event).
PS. this is how I view the difference between selection and filter:
- Filter: completely remove the "non-selected" data, and update the layout accordingly.
- Selection: dim the "non-selected" data, keeping the layout fixed.
from crosstalk.
I agree that direct vs. indirect is orthogonal to filter and selection. Your P.S. captures the most important distinctions between filter and selection, we're in agreement about that.
But one other important aspect is that there is only a single "selected" state for a given group, and whoever mutates it last completely overrides any previous values; while for filters, each widget or whatever has its own handle that has its own independent state (set of keys), and the group's overall filter state is the intersection of all of those sets.
Therefore, it totally makes sense that you created a selectize widget that both sets and responds to the selection state; whenever a selection event occurs in another widget, just override your current state to reflect the new state. But doing so with a filter control is a different proposition; when another filter component has changed its contribution to the overall filter state, what does that mean for your state?
There is at least one good answer I know of to that hypothetical question, which is, your state doesn't change but you filter down your visible choices to the intersection of every other filter handle's set except your own. But I don't think you can implement this with Crosstalk today, and I made that decision consciously.
I get that having filter controls that respond to other filter controls is a reasonable and quite desirable feature, e.g. pretty much every dc.js/crossfilter demo. I punted on this scenario for v1 of crosstalk--not because the crosstalk part of it would be difficult to implement, but because the burden on widget developers to support this correctly seemed unreasonably high (unless you started writing your widget from scratch with this kind of interconnected filtering in mind, as was the case for dc.js).
from crosstalk.
Ah, I see, I didn't know that about the automatic filter state resolution, which makes sense. That now makes me wonder: wouldn't it make sense to update a filter's choices based on the current state?
Also, I agree that a filter's current value shouldn't react to whatever another filter is doing (essentially because of the AND logic -- for details, see below).
Anyway, I still think there should be some sort way to set a filter's value at print time #16 (comment)
But one other important aspect is that there is only a single "selected" state for a given group, and whoever mutates it last completely overrides any previous values; while for filters, each widget or whatever has its own handle that has its own independent state (set of keys), and the group's overall filter state is the intersection of all of those sets.
What you are describing for the overall filter state sounds like something I'd call persistent selection, with AND logic, and a filter operation. In plotly, I've mostly been thinking about and implementing transient/persistent selection, with OR logic, and a brush/select operation. Of course, AND is more intuitive for a filter operation, but I'd argue OR is more intuitive for brushing, especially if the goal is to make comparisons. https://vimeo.com/190011823
For brushing, there are good use cases for logic other than OR (cranvas has this), and it's on my TODO list to implement.
Therefore, it totally makes sense that you created a selectize widget that both sets and responds to the selection state; whenever a selection event occurs in another widget, just override your current state to reflect the new state. But doing so with a filter control is a different proposition; when another filter component has changed its contribution to the overall filter state, what does that mean for your state?
It depends on the logic for resolving the selection sequence. At this time, I have no issue with always using AND logic for filter operations, but selection/brushing is another ball-game.
In fact, I think crosstalk's selection handle should have a more explicit way to set/get the selection mode (i.e., transient/persistent) and the logic (e.g., OR, AND, XOR, COMPLEMENT). At the very least, that would make this leaflet hack to respect plotly's persistent mode more official. That's not to say crosstalk should automatically resolve the selection state, though. Mainly just a more official mechanism to track the selection history and logic.
from crosstalk.
crosstalk::filter_checkbox leaflet is not working when I add a second addCircles to leaflet. The filter stops working. See minimal example below. I apologize in advance is this question is not according to form, I am new to rstudio and this is my first questions.
title: "crosstalk::filter_checkbox leaflet"
output: html_document
date: "2022-12-14"
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
library(leaflet)
library(crosstalk)
tstd = data.frame(lng=-116.3013+rnorm(10)/100,lat=33.1005+rnorm(10)/100,
Level1=c("L","L","L","L","L","H","H","H","H","H"))
sd_tstd <- SharedData$new(tstd)
crosstalk::filter_checkbox("Level1", "Level One", sd_tstd, ~Level1, inline = T)
leaflet(sd_tstd) %>% addTiles() %>% setView(-116.3013, 33.1005, zoom=13) %>%
addCircles(lng=~lng, lat=~lat, radius=99, stroke=T , weight=1, fill="Grey", color="black", opacity=1, group = "No Fill" ) %>% addCircles(lng=~lng, lat=~lat, radius=99, stroke=T , weight=1, fill="Blue", color="black", opacity=1, group = "With Fill" )
from crosstalk.
Related Issues (20)
- SharedData objects do not "select" properly when data has one row HOT 2
- Box plot: numeric vs categorical variables
- Readjusting axes on plotly plot after filtering
- Firefox remembers checkbox state on reload but data no longer filtered by filter_checkbox.
- Highlight in plotly figure breaks in shiny app when fixed group argument is used in SharedData$new()
- filter_checkbox sends filter value =null on first deselect
- How to show number of matching entries next to checkbox filter? HOT 1
- How to order checkbox filters by number of entries or factor level?
- Visible expression of filter_select selection
- Documentation mismatch `SharedData$data(withSelection=TRUE)` creates column named `selected_` not `selection_`
- filter_select: selecting the `(All)` option results in a javascript error HOT 1
- crosstalk.FilterHandle doesn't return the same type consistently
- Possible regression bug: SharedData across shiny modules HOT 2
- add "htmlwidget" class to `bscols()` object HOT 2
- modify filter_select height
- Release crosstalk 1.2.1
- Reactable Pagination Switches to Page One on Selection in Crosstalk Object HOT 4
- Data selection in DataTable with more than 10 entries and sigmajs faulty
- multiple filter_select with subsetting choices
- Filtering not working with `renderDT` in `flexdashboard`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crosstalk.