Currently, Vega does not support interactive axis labels, i.e. creating a selection via clicking on labels of an axis (see issue 1657), and so neither does Altair.
Therefore I am trying to find a work-around by providing legend selection and changing the appearance of the axis labels.
I am able to color labels conditionally (see code example below).
import altair as alt
from vega_datasets import data
source = data.unemployment_across_industries.url
selection = alt.selection_multi(fields=['series'], bind='legend')
alt.Chart(source).mark_bar().encode(
alt.X('series:N', axis=alt.Axis(labelColor=alt.condition('datum.value == "Finance"', alt.value('red'), alt.value('black')))),
alt.Y('sum(count):Q'),
alt.Color('series:N', scale=alt.Scale(scheme='category20b')),
opacity=alt.condition(selection, alt.value(1), alt.value(0.2))
).add_selection(
selection
)
However, I get an error when trying to use a selection instead of an expression.
alt.X('series:N', axis=alt.Axis(labelColor=alt.condition(selection, alt.value('red'), alt.value('black')))),
Is there any way of connecting the label appearance to a selection (here: bound to the legend)?
