Vega Multi Selection not working

Hi,

I am playing around with Vega Selection. Therefore I tried the examples from the Reference Gallary.

Unfortunately, using selection_interval works as expected, but selection_multi isn´t.

Running this code in jupyter:

import panel as pn
import altair as alt

pn.extension("vega")


penguins_url = (
    "https://raw.githubusercontent.com/vega/vega/master/docs/data/penguins.json"
)


# SELECTION_INTERVAL
brush = alt.selection_interval(name='brush')  # selection of type "interval"

chart = alt.Chart(penguins_url).mark_point().encode(
    x=alt.X('Beak Length (mm):Q', scale=alt.Scale(zero=False)),
    y=alt.Y('Beak Depth (mm):Q', scale=alt.Scale(zero=False)),
    color=alt.condition(brush, 'Species:N', alt.value('lightgray'))
).properties(
    width=250,
    height=250
).add_selection(
    brush
)

vega_pane = pn.pane.Vega(chart, debounce=10)

# SELECTION_MULTI
multi = alt.selection_multi(name='multi')  # selection of type "multi"

multi_chart = alt.Chart(penguins_url).mark_point().encode(
    x=alt.X('Beak Length (mm):Q', scale=alt.Scale(zero=False)),
    y=alt.Y('Beak Depth (mm):Q', scale=alt.Scale(zero=False)),
    color=alt.condition(multi, 'Species:N', alt.value('lightgray'))
).properties(
    width=250,
    height=250
).add_selection(
    multi
)

vega_multi = pn.pane.Vega(multi_chart, debounce=10)

pn.Row(vega_pane, vega_multi)

Selecting some points in both charts and executing:

print("Interval Selection:", vega_pane.selection.brush)
print("Multi Selection:",vega_multi.selection.multi)

gives

Interval Selection: {‘Beak Length (mm)’: [43.725, 52.125], ‘Beak Depth (mm)’: [13.792, 15.879999999999999]}
Multi Selection: []

Any ideas, what´s the problem here?

EDIT:

Ìt is working, when I am using .show().

pn.Row(vega_pane, vega_multi).show()

Hi @legout

I tried it out but I cannot see any issues. It works for me.

Thanks. That’s interesting.

I’ll do a test on my Mac Mini at home and will setup a new virtual environment on my PC at work.

1 Like