Skip to content

Altair incorrectly combines parameters with the same properties instead of assigning them unique IDs #3891

@joelostblom

Description

@joelostblom

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)) & bars

If 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions