Selection Multi Init
See original GitHub issueIs there public documentation for how to pass initial values to selection multi. For example in this chart from the documentation how can I make the initial selection Japan
and USA
. Is there a way to pass init to alt.selection_multi to make this happen?
selection = alt.selection_multi(fields=['Origin'])
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_point().encode(
y=alt.Y('Origin:N', axis=alt.Axis(orient='right')),
color=color
).add_selection(
selection
)
scatter | legend
I’ve tried doing something like the following but this appears to have no effect.
import altair as alt
from vega_datasets import data
cars = data.cars.url
selection = alt.selection_multi(
fields=['Origin'],
init=[{'Origin': 'USA'}, {'Origin': 'Japan'}]
)
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_point().encode(
y=alt.Y('Origin:N', axis=alt.Axis(orient='right')),
color=color).add_selection(selection)
scatter | legend
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
altair.selection_multi — Altair 4.2.0 documentation
"multi" – to select multiple discrete data value; the first value is ... Initialize the selection with a mapping between projected channels or...
Read more >How to have init values for a selection interval in Altair when ...
I'm trying to have initial values for a selection_interval in a Altair plot, but I've been unable to figure it out. Here is...
Read more >altair.MultiSelection — Altair 4.1.0 documentation
"multi" – to select multiple discrete data value; the first value is selected on click and additional values toggled on shift- click ....
Read more >Grid multi-select, initialize with multiple selected - EJ 2 Forums
I'm trying to use the enableSimpleMultiRowSelection of the GridComponent, and want to select rows initially for my component when it renders.
Read more >Multiple Unit Selection in Unity || RTS, Diablo, City Builder ...
In this video we'll build a simple unit selection system.It includes single selection, and multiple selections with shift click and also a ...
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
Your example is working for me:
The jupyterlab vega extension uses an older version of vega/vega-lite, I belive. Colab is up-to-date as of the Altair 3.2 release. I checked with the vega-editor, and the chart does not work in Vega-Lite 4 either.
I suspect it was a regression in Vega-Lite somewhere along the way; may be worth opening an issue there.