Composing Multiple Selections
See original GitHub issueWhat is the best approach for combining multiple selections in Altair? In Vega-Lite this is described as such for a combined conditioned color selection:
"color": {
"condition": {
"selection": {"and": ["alex", "morgan"]},
"aggregate": "count", "type": "quantitative"
},
"value": "grey"
}
And I can create a working example similar to the Vega-Lite docs as such in Altair:
import altair as alt
from vega_datasets import data
source = data.cars()
alex = alt.selection_interval(
on="[mousedown[!event.shiftKey], mouseup] > mousemove",
translate="[mousedown[!event.shiftKey], mouseup] > mousemove",
name='alex'
)
morgan = alt.selection_interval(
on="[mousedown[event.shiftKey], mouseup] > mousemove",
translate="[mousedown[event.shiftKey], mouseup] > mousemove",
mark={"fill": "#fdbb84", "fillOpacity": 0.5, "stroke": "#e34a33"},
name='morgan'
)
alt.Chart(source).mark_rect().encode(
x='Cylinders:O',
y='Origin:O',
color=alt.condition({"selection": {"and": [alex.name, morgan.name]}}, 'count()', alt.ColorValue("grey"))
).add_selection(
alex, morgan
)
But it doesn’t feel very pythonic.
I saw there is an alt.SelectionAnd()
function, but I don’t know how it should work. I tried alt.SelectionAnd([alex.name, morgan.name])
, but this returns:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-55-409c05815fbc> in <module>
----> 1 alt.SelectionAnd([alex.name, morgan.name])
TypeError: __init__() takes 1 positional argument but 2 were given
Some help, advice or insight is appreciated.
(I’m also not sure if the on
and translate
within the alt.selection_interval()
function should be like this in Altair)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Multiple choices in a list with compose
Multiple choices in a list with compose. Jetpack Compose is Android's modern toolkit for building native UI. It simplifies and accelerates ...
Read more >How to implement list multiSelect in Jetpack Compose?
Show activity on this post. Add selected field to some class representing the item. Then just compose proper code based on that field....
Read more >jetpack compose lazy column multiple item selection - YouTube
jetpack compose lazy column multiple item selection | jetpack compose lazycolumn items selectionToday we're going to make an example of ...
Read more >Lazy Column Multiple Item Selection in Android Jetpack ...
In this Video We are going to Implement Multi Select Options in Lazy Column of Android Jetpack Compose.Build better apps faster with Jetpack ......
Read more >14 RULES FOR WRITING MULTIPLE-CHOICE QUESTIONS
14 RULES FOR WRITING MULTIPLE-CHOICE QUESTIONS. 1. Use Plausible Distractors (wrong-response options). • Only list plausible distractors, even if the number ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I guess here: https://altair-viz.github.io/user_guide/interactions.html#selection-types-interval-single-multi. I should be able to add this example as a PR later this week, but this part:
is a bit verbose. But we can discuss this in that PR.
Great! Is there any place in the docs we could add this that you might have found before asking the question?