I want to control the length of Horizontal bar because when animation ends some of the values does not fit inside the bars. In the image below value of Air Canada does not fit inside the bar so I want to increase the overall length of all the bars proportionally or take the label outside the bar.
Also during the animation I get the passenger count as decimal value which does not make sense,I have tried to control it using numberFormat
and maxFractionDigits
but no success.
filter_format = "(" + \
" || ".join([f"record['Operating Airline'] == '{item}'" for item in top10_airlines]) + ")"
config = {
"channels": {
"y": {
"set": ["Operating Airline"],
},
"x": {"set": ["Passenger Count"]},
"label": {"set": ["Passenger Count"]},
"color": {"set": ["Operating Airline"]},
},
"sort": "byValue",
}
style = Style(
{
"plot": {
"paddingLeft": 120,
"paddingTop": 25,
"yAxis": {
"color": "#ffffff00",
"label": {"paddingRight": 10},
},
"xAxis": {
"title": {"color": "#ffffff00"},
"label": {
"color": "#ffffff00",
#"numberFormat": "grouped",
#"numberFormat": "prefixed",
"maxFractionDigits":"0",
},
},
"marker": {
"colorPalette": "#d9ed92ff #b5e48cff #99d98cff #76c893ff #52b69aff"
+ " #34a0a4ff #168aadff #1a759fff #1e6091ff #184e77ff"
},
},
}
)
chart = Chart(display=DisplayTarget.END)
#chart.animate(data.filter(filter_format), style)
chart.animate(data, style)
#chart.animate(Config(config))
for year in years:
config["title"] = f"Airlines Passenger Count in {year}"
#print(month)
chart.animate(
Data.filter(f"parseInt(record.Year) == {year} && {filter_format}"),
Config(config),
duration=1,
x={"easing": "linear", "delay": 0},
y={"delay": 0},
show={"delay": 0},
hide={"delay": 0},
title={"duration": 0, "delay": 0},
)
chart.animate(
Config(
{
"channels": {
"x": {"attach": ["Year"]},
#"label": {"set": "Passenger Count"},
}
}
),
duration=1,
)
chart.feature("tooltip", True)