Open joelostblom opened 2 months ago
The following code works as expected:
click = alt.selection_point(empty=False) ctrl_click = alt.selection_point(on='click[event.ctrlKey]', empty=False) points = alt.Chart(data.cars.url).mark_point().encode( x='Horsepower:Q', y='Miles_per_Gallon:Q', fill=alt.condition(ctrl_click, alt.value('red'), alt.value('white')), size=alt.condition(click, alt.value(1000), alt.value(50)) ).add_params( click, ctrl_click ) points
Open the Chart in the Vega Editor
However, when changing the fill condition to include a parameter composition:
fill=alt.condition(ctrl_click & click, alt.value('red'), alt.value('white')),
The value empty=False is no longer respected for that encoding channel:
empty=False
In the VL spec you can see that this happens because Altair converts the parameter composition into the following VL:
"condition": { "test": {"and": [{"param": "param_208"}, {"param": "param_207"}]}, "value": "red" },
The correct conversion to VL would look like this:
"condition": { "test": {"and": [{"param": "param_208", "empty": false}, {"param": "param_207", "empty": false}]}, "value": "red" },
Not sure how long this has been present, but as I show above it is not related to the resent introduction of when since it also happens with condition.
when
condition
5.4.1
This is unrelated to both condition and when.
All of these Parameter methods use Parameter.name only
Parameter
Parameter.name
Parameter.(empty|param|param_type)
https://github.com/vega/altair/blob/62cd37774cc1abfe2905b2ae554c75ee33a65907/altair/vegalite/v5/api.py#L391-L421
What happened?
The following code works as expected:
Open the Chart in the Vega Editor
However, when changing the fill condition to include a parameter composition:
The value
empty=False
is no longer respected for that encoding channel:Open the Chart in the Vega Editor
In the VL spec you can see that this happens because Altair converts the parameter composition into the following VL:
What would you like to happen instead?
The correct conversion to VL would look like this:
Not sure how long this has been present, but as I show above it is not related to the resent introduction of
when
since it also happens withcondition
.Which version of Altair are you using?
5.4.1