A predicate to check whether a selection is empty or not #4371
Labels
Area - Interaction
Help Wanted
Good tasks for contributors (try https://github.com/vega/vega-lite/issues/1486 first)
P2
Important Issues that should be fixed soon
RFC / Discussion 💬
For discussing proposed changes
Milestone
Our selection can include
empty: "all" | "none"
. However, sometimes, we want to apply each of the modes to a different part of the same visualization.For example, in https://vega.github.io/vega-lite/examples/interactive_bar_select_highlight.html:
fillOpacity
to activate the selection predicate both when there are selected data for theselect
selection and when there is none.select
selection, but not when there is none. Currently, I had to add a hack where I have to combine an expression with the selection predicate:Note that the expression
"length(data(\"select_store\"))"
is a hack as I know the underlying data store name in Vega.It would be more natural to provide a syntax for this as a part of a selection predicate (and a condition definition).
The tricky part is that the new syntax that we can add here may be overriding the "empty" defined.
Some alternatives (given a selection named
select
):a) Add
{empty: "sel_name"}
to the selection logical chainb) Add
{empty: "sel_name"}
to the predicate chainc) Add boolean empty to both the selection predicate and condition predicate
For this c) design we can also add
"empty"
to the selection predicate too:{"selection": "select", "empty": false}
After writing these alternatives, I think c) is probably the most user-friendly.
@arvind @domoritz
The text was updated successfully, but these errors were encountered: