diff --git a/src/gasflux/reporting.py b/src/gasflux/reporting.py index a5bc2be..23de789 100644 --- a/src/gasflux/reporting.py +++ b/src/gasflux/reporting.py @@ -27,13 +27,22 @@ def mass_balance_report( """Generate a mass balance report (plots disabled).""" template_path = Path(__file__).parent / "templates" / "mass_balance_template.html" - # Plots disabled -> use empty strings + # Convert figures to HTML strings + def _fig_to_html(fig) -> str: + """Safely convert a plotly figure to HTML string.""" + if fig is None: + return "" + try: + return fig.to_html(full_html=False, include_plotlyjs=True) + except Exception: + return "" + plot_htmls = { - "3D": "", - "krig": "", - "windrose": "", - "wind": "", - "background": "", + "3D": _fig_to_html(threed_fig), + "krig": _fig_to_html(krig_fig), + "windrose": _fig_to_html(windrose_fig), + "wind": _fig_to_html(wind_fig), + "background": _fig_to_html(background_fig), } summary_data = {