-
-
Notifications
You must be signed in to change notification settings - Fork 826
Description
What happened?
The example from #3628 does still not work correctly in the docs, but now for a new reason. It seems that when two parameters in the same spec have the same properties, Altair assigns them the same name so that they are combined to the same parameter in the VL spec.
As an example, for the altair code below, I would expect there to be two different param IDs generate, so that I need to make a selection in both charts to trigger the bars to show up. Instead, I only need to select in one chart, since it is the same param name that is used as you can see in the corresponding VL spec.
import altair as alt
from altair.datasets import data
cars = data.cars.url
# empty=False ensure that no points are selected before a selection is drawn
brush = alt.selection_interval(empty=False)
brush2 = alt.selection_interval(empty=False)
points = alt.Chart(cars).mark_point(size=10).encode(
x='Horsepower:Q',
y='Miles_per_Gallon:Q',
color='Origin:N'
)
points2 = points.encode(
x='Acceleration:Q',
y='Miles_per_Gallon:Q',
)
bars = alt.Chart(cars).mark_bar().encode(
x='count()',
y='Origin:N',
color='Origin:N'
).transform_filter(
brush & brush2
)
(points.add_params(brush) | points2.add_params(brush2)) & barsIf the second param is changed to the following, two unique parameters are created and the example works as expected:
brush2 = alt.selection_interval(empty=False, name='another param')What would you like to happen instead?
Altair should always assign unique IDs to distinct parameters instead of combining them into the same parameter name.
Which version of Altair are you using?
main