diff --git a/scripts/generate_reports.py b/scripts/generate_reports.py
index 664a3a5..e587e6e 100644
--- a/scripts/generate_reports.py
+++ b/scripts/generate_reports.py
@@ -58,14 +58,17 @@ def _save_json(path: Path, data: List[Dict]) -> None:
def _copy_icons() -> None:
- """Copy vendored icons to the output directory."""
+ """Copy vendored icons and scripts to the output directory."""
src_dir = Path("static/icons")
dst_dir = OUTPUT_DIR / "icons"
- if not src_dir.is_dir():
- return
- dst_dir.mkdir(parents=True, exist_ok=True)
- for icon in src_dir.glob("*.svg"):
- shutil.copy(icon, dst_dir / icon.name)
+ if src_dir.is_dir():
+ dst_dir.mkdir(parents=True, exist_ok=True)
+ for icon in src_dir.glob("*.svg"):
+ shutil.copy(icon, dst_dir / icon.name)
+
+ js_src = Path("static/chartManager.js")
+ if js_src.is_file():
+ shutil.copy(js_src, OUTPUT_DIR / js_src.name)
def _render_snippet(report: Dict, out_dir: Path) -> None:
diff --git a/static/chartManager.js b/static/chartManager.js
new file mode 100644
index 0000000..79d83fc
--- /dev/null
+++ b/static/chartManager.js
@@ -0,0 +1,49 @@
+export let currentLoad = null;
+const loadInfo = new Map();
+
+export function newLoad(container) {
+ if (currentLoad) {
+ abortLoad(currentLoad);
+ }
+ reset(container);
+ const controller = new AbortController();
+ const token = { controller, charts: new Map() };
+ loadInfo.set(token, token);
+ currentLoad = token;
+ return token;
+}
+
+export function abortLoad(token) {
+ const info = loadInfo.get(token);
+ if (!info) return;
+ info.controller.abort();
+ info.charts.forEach(chart => {
+ try {
+ chart.destroy();
+ } catch (e) {}
+ });
+ loadInfo.delete(token);
+ if (currentLoad === token) {
+ currentLoad = null;
+ }
+}
+
+export function registerChart(token, id, chart) {
+ const info = loadInfo.get(token);
+ if (info) {
+ info.charts.set(id, chart);
+ } else {
+ chart.destroy();
+ }
+}
+
+export function reset(container) {
+ if (!container) return;
+ container.querySelectorAll('canvas').forEach(c => {
+ const chart = Chart.getChart(c);
+ if (chart) {
+ chart.destroy();
+ }
+ });
+ container.innerHTML = '';
+}
diff --git a/templates/index.html b/templates/index.html
index 84c6214..1b27003 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -72,7 +72,14 @@
-