Skip to content

Commit

Permalink
fix(to_figure): Update legend position when more data is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
devang-chauhan committed Jan 27, 2022
1 parent 2ad9041 commit 6e1269b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ladybug_charts/to_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ def bar_chart(data: Union[List[MonthlyCollection], List[DailyCollection]],
f'Title is set to "{title}" but show_title is set to False.')
fig_title = None

# move legend upwards as mode data is loaded
legend_height = 1.2 if len(data) <= 3 else 1.2 + (len(data)-3)/10

fig.update_layout(
barmode='relative' if stack else 'group',
template='plotly_white',
Expand All @@ -295,7 +298,7 @@ def bar_chart(data: Union[List[MonthlyCollection], List[DailyCollection]],
title=fig_title,
legend={
'x': 0,
'y': 1.2,
'y': legend_height,
}
)
fig.update_xaxes(dtick="M1", tickformat="%b", ticklabelmode="period",
Expand Down

0 comments on commit 6e1269b

Please sign in to comment.