Код: Выделить всё
base = alt.Chart(df).transform_joinaggregate(total='sum(quantity)')\
.transform_calculate(percentage='datum.quantity / datum.total')\
.mark_bar(size=50)\
.encode(alt.X('sum(percentage):Q', title=None).axis(format='.1%'),
order=alt.Order('status:N', sort='descending'))\
.interactive()
bars = base.encode(alt.Color('voltooid', scale=alt.Scale(domain=['started', 'finished'],
range=['darkblue', 'gray']),
legend=alt.Legend(orient='bottom', title=None)))
text = base.mark_text(align='center', baseline='middle', fontSize=20,
fontWeight='bold', color=colors.Wit, dx=100)\
.encode(text=alt.Text('sum(quantity):Q'))
bars + text
введите здесь описание изображения
Подробнее здесь: https://stackoverflow.com/questions/798 ... -in-altair
Мобильная версия