This is the code I am using to build the bar chart itself:
bar = alt.Chart(selected_publication_total_subs_df).transform_joinaggregate(
TotalSubCnt='sum(subscriber_cnt)'
).transform_calculate(
PercentOfTotal='datum.subscriber_cnt / datum.TotalSubCnt'
).mark_bar().encode(
x=alt.X('yearmonthdate(as_of_date):O', axis=alt.Axis(title='', labelFontSize=12, labelPadding=10, labelAngle=-45)),
y=alt.Y('sum(subscriber_cnt)', stack='normalize', axis=alt.Axis(format='%', title='% of Subscriber Count' ,labelFontSize=12, labelPadding=10, titleFontSize=16, titlePadding=20)),
color=alt.Color('status'),
opacity=alt.condition(legend_selection, alt.value(1), alt.value(0.1))
).properties(width=1000,height=400).add_selection(legend_selection)
It is resulting in this visual:
