Multi selection without pressing shift key?
See original GitHub issueIs it possible to do a multi selection without holding down the shift key?
I would like to single click on fields in the legend chart to toggle selection. Normal behavior is shift-click.
import altair as alt
from vega_datasets import data
cars = data.cars.url
selection = alt.selection_multi(fields=['Origin', 'Cylinders'])
color = alt.condition(selection,
alt.Color('Origin:N', legend=None),
alt.value('lightgray'))
scatter = alt.Chart(cars).mark_point().encode(
x='Horsepower:Q',
y='Miles_per_Gallon:Q',
color=color,
tooltip='Name:N'
)
legend = alt.Chart(cars).mark_rect().encode(
y=alt.Y('Origin:N', axis=alt.Axis(orient='right')),
x='Cylinders:O',
color=color
).add_selection(
selection
)
scatter | legend

Things I have tried that had no effect:
selection = alt.selection_multi(on='click', fields=['Origin', 'Cylinders'])
selection = alt.selection_multi(on='mousedown', fields=['Origin', 'Cylinders'])
Using either of
selection = alt.selection_multi(on='click[event.altKey]', fields=['Origin', 'Cylinders'])
selection = alt.selection_multi(toggle='event.altKey', fields=['Origin', 'Cylinders'])
I can change the modifier from shift to alt, but I don’t understand how I can enter no modifier. If I use toggle=''
the legend reacts as if using toggle=False
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How do I select multiple objects without holding down shift?
Go to the File - Options and select the icon for multiple objects selection. Once ticked, you can slect the multiple objects without...
Read more >Unable to use Shift key to select multipl… - Apple Community
Unable to use Shift key to select multiple items in between for selection ; Step 1: Finder > Click Go at the top...
Read more >can't use shift key to select multiple photos, files or objects
To select multiple files and folders, you hold down Control then click on the icon or image. Shift will simply select everything.
Read more >Selecting multiple list items - ConfTool
Click the first item, then press the SHIFT key and hold it. Click the last item and release the SHIFT key. To select...
Read more >How do I select multiple items when there are no check boxes ...
Hold down the shift key and click on the last item in a row that you want selected. The second way to do...
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 Free
Top 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
This part of the docs is generated directly from the descriptions within the Vega-Lite schema, and we have no mechanism to make altair-specific spot-corrections like this. But the docs do mention that toggle takes a string containing a vega expression. Perhaps its not clear that
'true'
(the vega expression) is different fromtrue
(the boolean default in Vega-Lite, represented byTrue
in Python). If you’re interested, you could send a pull request to the Vega-Lite project clarifying the part of that relevant to Vega-Lite, and it would be reflected in Altair once Altair wraps the Vega-Lite release containing that update.Regarding the fact that vega-lite
true
is equivalent to PythonTrue
, I’m not certain how we can better convey that given that the docs are auto-generated.We could theoretically override Vega-Lite docs with Python-specific versions, but that’s not a maintenance burden that I’m willing to take on.
The doc modification is now in the latest vega-lite release (4.12.2)