composing multiple selections
@@ -251,6 +251,50 @@ over them with your mouse:
multi_mouseover = alt.selection_multi(on='mouseover', toggle=False, empty='none')
make_example(multi_mouseover)
+Composing Multiple Selections
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Altair also supports combining multiple selections using the `&`, `|` and `~`
+for respectively `AND`, `OR` and `NOT` logical composition operands.
+
+In the following example there are two people who can make an interval selection
+in the chart. The person Alex makes an selection box when the control-key is
+selected and Morgan can make an selection box when the shift-key is selected.
+We use the alt.Brushconfig() to give the selection box of Morgan a different
+style.
+Now, we color the rectangles when they fall within Alex's or Morgan's selection.
+
+.. altair-plot::
+
+ alex = alt.selection_interval(
+ on="[mousedown[event.ctrlKey], mouseup] > mousemove",
+ name='alex'
+ )
+ morgan = alt.selection_interval(
+ on="[mousedown[event.shiftKey], mouseup] > mousemove",
+ mark=alt.BrushConfig(fill="#fdbb84", fillOpacity=0.5, stroke="#e34a33"),
+ name='morgan'
+ )
+
+ alt.Chart(cars).mark_rect().encode(
+ x='Cylinders:O',
+ y='Origin:O',
+ color=alt.condition(alex | morgan, 'count()', alt.ColorValue("grey"))
+ ).add_selection(
+ alex, morgan
+ ).properties(
+ width=300,
+ height=180
+ )
+
+With these operators, selections can be combined in arbitrary ways:
+
+- "selection": {"not": {"and": ["alex", "morgan"]}}: to select the rectangles
+that fall outside Alex's and Morgan's selections.
+- alex | ~morgan: to select the rectangles that fall within Alex's selection or
+outside the selection of Morgan
+
+
Selection Targets: Fields and Encodings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For any but the simplest selections, the user needs to think about exactly
