Encapsulate svg conversion

This commit is contained in:
Felix Blanke 2023-08-28 17:12:06 +02:00
parent 45647def39
commit c5f6067e8b

10
wsgi.py
View File

@ -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'<font color="red">{key} 10:00:00</font>')
_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),
)