feat(results): lap chart per qualifying heat and final in the race overview, print and PDF (1.89.32)

This commit is contained in:
larssand committed 2026-11-14 20:55:44 +01:00
1 parent 01998952a7
commit 6a036899ab
15 files changed
+245 -14

No files matched your search

+17
View File
@@ -961,6 +961,22 @@ function attachmentDisposition(filename) {
return `attachment; filename="${ascii}"; filename*=UTF-8''${encodeURIComponent(name)}`;
}
// A heat's lap chart (src/lap_chart_logic.js): places per lap per driver, drawn as lines.
function normalizePdfLapChart(chart) {
if (!chart || !Array.isArray(chart.series)) return null;
const laps = Math.min(400, Math.max(0, Math.floor(Number(chart.laps) || 0)));
const series = chart.series.slice(0, 24).map((serie) => ({
name: String(serie?.name || "-").slice(0, 60),
color: /^#[0-9a-f]{6}$/i.test(String(serie?.color || "")) ? String(serie.color) : "#555555",
positions: (Array.isArray(serie?.positions) ? serie.positions : []).slice(0, laps).map((place) => {
const value = Math.floor(Number(place));
return value >= 1 && value <= 24 ? value : null;
}),
}));
if (laps < 2 || series.length < 2) return null;
return { title: String(chart.title || "").slice(0, 80), lapLabel: String(chart.lapLabel || "").slice(0, 20), laps, series };
}
function normalizePdfExportPayload(input = {}) {
const title = String(input.title || "RC RaceCore").trim();
const subtitle = String(input.subtitle || "").trim();
@@ -982,6 +998,7 @@ function normalizePdfExportPayload(input = {}) {
: [],
// A country code per row for the flag before the driver's name ("SE", "GB-ENG"); anything else is dropped.
flags: Array.isArray(section?.flags) ? section.flags.map((code) => (/^[A-Z]{2}(-[A-Z]{3})?$/.test(String(code || "")) ? String(code) : "")) : [],
chart: normalizePdfLapChart(section?.chart),
}))
: [];