"""Graphs routes — interactive charts via Plotly.js. Replaces Java I2P's JRobin server-side PNG rendering with client-side interactive charts. Ported from net.i2p.router.web.helpers.GraphHelper / SummaryListener. """ from __future__ import annotations from flask import Blueprint, render_template, current_app, jsonify bp = Blueprint("graphs", __name__) @bp.route("/graphs") def graphs(): """Graphs overview page with Plotly.js charts.""" return render_template("graphs.html") @bp.route("/graphs/data/") def graph_data(stat_name: str): """JSON endpoint for chart data.""" stats = current_app.config.get("STATS_COLLECTOR") if stats is None: return jsonify({"labels": [], "values": []}) samples = stats.get(stat_name) return jsonify({ "labels": [s.timestamp for s in samples], "values": [s.value for s in samples], })