diff --git a/wsgi.py b/wsgi.py index 25ed44c..bf1fc9c 100644 --- a/wsgi.py +++ b/wsgi.py @@ -173,6 +173,10 @@ def plot( plt.tight_layout() + return fig + + +def convert_fig_to_svg(fig: plt.Figure) -> str: # Convert plot to SVG image imgdata = io.StringIO() fig.savefig(imgdata, format="svg") @@ -228,7 +232,7 @@ def tables( df_state = df_state.sort_values("Landesbezirk") - image = plot(df_state) + fig = plot(df_state) timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") except Exception as e: @@ -245,7 +249,7 @@ def tables( {"Digitale Befragung": "Int32"} ) - image = plot() + fig = plot() timestamp = Markup(f'{key} 10:00:00') _print_as_html(df_state) @@ -255,7 +259,7 @@ def tables( "base.html", tables="\n".join(output_str), timestamp=timestamp, - image=image, + image=convert_fig_to_svg(fig), )