Closed joelostblom closed 2 years ago
I can't get single and multi selection to work. Following the example on Vega Reference Gallery
import altair as alt
from vega_datasets import data
penguins_url = "https://raw.githubusercontent.com/vega/vega/master/docs/data/penguins.json"
df = pd.read_json(penguins_url)
multi = alt.selection_multi(name='multi') # selection of type "multi"
multi_chart = alt.Chart(df).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)
vega_multi
I'm using the following versions panel=0.13.1 altair=4.2.0
This works fine for me. Same versions as you. Two things could cause the problem: You haven't added vega to the extension: pn.extension("vega")
. Your cell count is pretty high, try to restart and run all cells in the notebook.
I tested again:
pn.extension('vega')
but it still doesn't work.
Try launching the jupyter lab from your fresh environment.
Though, this is more of a usage question and would be better to continue on Discourse.
After clicking a point in the chart, I see vega_multi.selection collects index number of the data point. But if data points are plotted after "transform_aggregate" in Altair, then the re-indexed number of the aggregation are collected in the vega_multi.selection. But I don't know how I can relate the re-indexed number to my dataset because aggregation is performed by altair internally. Do you have any idea?
@jhyoo1982 Could you provide a minimal reproducible example of your issue? It would help the developers to quickly troubleshoot it by copy pasting your code and seeing what the issue is. It could also be a good idea to open a separate issue for this with all the details.
Thanks for adding support for Altair/Vega events in this release, that’s very exciting! And congrats on releasing 0.13, I'm very excited about the future wasm support and possibility of standalone desktop installers as well.
I noticed that the Altair examples in the docs does not work if I change the Altair selection from interval to a point selection (single or multi). These return an empty dictionary, whereas an interval selections returns something like
It would be great if point selections were also supported. Maybe they are and there is just a different syntax needed (then an example in the docs would be great). Also note that
selection_multi
andselection_single
will be merged toselection_point
in the next version of Altair and behave likeselection_multi
by default (so it shouldn't have a big impact on the implementation of this feature in panel).Full example:
Ref https://github.com/holoviz/panel/issues/3397