Make create_fig more general

This commit is contained in:
Felix Blanke 2023-09-01 14:46:37 +02:00
parent ef8cab6330
commit f9c14e442b

14
wsgi.py
View File

@ -198,6 +198,8 @@ def plot(
def create_fig(
url: str = "https://beschaeftigtenbefragung.verdi.de/",
importance_factor: float = 1.0,
landesbez_strs: list[str | None] | None = None,
fix_lims: bool = True,
):
curr_datetime = datetime.datetime.now()
try:
@ -233,17 +235,19 @@ def create_fig(
timestamp = Markup(f'<font color="red">{key} 10:00:00</font>')
total = plot_df.loc[curr_datetime].sum()
landesbez_strs = [None] + [
bez
for bez in plot_df.columns
if plot_df.loc[curr_datetime][bez] >= importance_factor * total
]
if landesbez_strs is None:
landesbez_strs = [None] + [
bez
for bez in plot_df.columns
if plot_df.loc[curr_datetime][bez] >= importance_factor * total
]
return (
plot(
curr_datetime,
plot_df,
annotate_current=annotate_current,
landesbez_str=landesbez_strs,
fix_lims=fix_lims,
),
df,
df_state,