feat(export): lap times table with best and fastest laps marked in a heat's print and PDF (1.89.52)
This commit is contained in:
1 parent
fbc4246a60
commit
afe884d2fe
12 files changed
+141
-7
No files matched your search
@@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.89.52 - 2026-11-16
|
||||
|
||||
- Heat print and PDF: under the lap chart, every lap time in a table – a row per lap, a column per driver in finish order. Each driver's best lap is bold on green and the fastest lap of the heat bold on purple. Only with a single heat, so the full results stay short.
|
||||
|
||||
## 1.89.51 - 2026-11-16
|
||||
|
||||
- Run the day automatically no longer starts the preliminary qualifiers once practice is done: it waits, like before the finals, with "Waiting: practice is done – press Generate qualifying from practice".
|
||||
|
||||
@@ -116,6 +116,7 @@ The menu follows how a race day works: **Start** (Dashboard, Race Day), **Create
|
||||
- **▶ Run the day automatically** starts each heat's count-down on its own when the schedule says so, and waits (saying why) while a heat runs, the decoder is offline or a heat is not ready. With several classes on one day, every class's heats run in the same order. Finals are never created automatically: when a class's qualifying is done it says "Waiting: check qualifying and press 🏁 Create finals for …" with the class names, so qualifying can be corrected first. Then the autopilot runs the finals. It runs only in the browser where it was turned on. **■ Stop autopilot** to run heats by hand; turning it on again carries on with the next heat not yet run. **⏸ Pause the day** pauses the heat on track (or holds the count-down) and the autopilot until **Resume the day**.
|
||||
- **Race overview** (under the heat queue): the whole race of the current event in one place - the podium from the A final, then practice, qualifying and finals that open and close, each with the standings and every heat's result (laps, result, best lap, and the car in sponsor heats). **Print**, **PDF** and **CSV** export the whole race with every heat, finals on top (A final first), then qualifying, then practice. A finished heat or final has its own **🖨** and **PDF** buttons for just that heat, e.g. for the board in the pits.
|
||||
- **📈 Lap chart:** every qualifying heat and final has a fold-out lap chart - each driver's place after every lap as a coloured line, place 1 on top, names at their official finish place. Counted from the passings, nothing extra to set up. It is printed and in the PDF of a single heat, and with the finals in the full results.
|
||||
- **⏱ Lap times:** the print and PDF of a single heat also list every lap, a column per driver in finish order; each driver's best lap is bold on green and the fastest lap of the heat purple.
|
||||
- **Speaker panel** (under the start buttons): track call, track clear, red flag, pause, resume, false start and marshal warning. Under **Sound and calls** are quick switches that save at once: mute all, lap time calls, race leader calls, practice hype and the speaker cues.
|
||||
- **Preflight** checks the decoder, participants, transponders (missing or duplicated), the lap window, the grid and audio. Blockers come first, each with a shortcut to the right setting. The min/max lap time can be edited right there.
|
||||
- **An automatic SQLite backup** is taken before every start.
|
||||
|
||||
@@ -129,6 +129,7 @@ Gränssnittet finns på svenska och engelska.
|
||||
- **Heat-kön** visar aktuellt, nästa och därpå följande heat i körordning: träning, kval omgång för omgång (Q1 H1, Q1 H2, Q2 H1 …), sedan finaler från lägsta (C, B, A). När ett heat är klart väljer **▶ Nästa** nästa heat med ett klick. Sessionslistorna i Race Setup och på Race Day följer samma ordning, så ett heat som tagits bort och skapats om hamnar på rätt plats; **▲▼** på en session i Race Setup flyttar den tidigare eller senare.
|
||||
- **Race-översikt** (under heatkön): hela racet för det aktuella eventet på ett ställe – pallen från A-finalen, sedan träning, kval och finaler som kan fällas ut, var och en med ställning och varje heats resultat (varv, resultat, bästa varv, och bilen i sponsorheat). **Skriv ut**, **PDF** och **CSV** exporterar hela racet med alla heat, finalerna överst (A-finalen först), sedan kval och sist träning. Ett avslutat heat eller en final har egna knappar **🖨** och **PDF** för bara det heatet, t.ex. till tavlan i depån.
|
||||
- **📈 Varvdiagram:** varje kvalheat och final har ett utfällbart varvdiagram – varje förares placering efter varje varv som en färgad linje, 1:a överst, namnen vid den officiella placeringen. Räknas från passeringarna, inget att ställa in. Det kommer med i utskrift och PDF av ett enskilt heat, och med finalerna i hela resultatet.
|
||||
- **⏱ Varvtider:** utskrift och PDF av ett enskilt heat listar också alla varv, en kolumn per förare i placeringsordning; förarens bästa varv är fett på grönt och heatets snabbaste varv lila.
|
||||
- **Speakerpanel** (under startknapparna): stopp på banan, banan fri, röd flagg, paus, fortsätt, tjuvstart och banvaktsvarning. Under **Ljud och utrop** finns snabbval som sparas direkt: tysta allt, varvtidsutrop, ledarutrop, pepp under träning och speaker-utropen.
|
||||
- **Förkontrollen** kontrollerar decoder, deltagare, transpondrar (saknade eller dubbletter), varvtidsgränser, grid och ljud. Blockerare visas först, var och en med en genväg till rätt inställning. Min/max-varvtid kan ändras direkt där.
|
||||
- **En automatisk SQLite-backup** tas före varje start.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.51",
|
||||
"version": "1.89.52",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.51",
|
||||
"version": "1.89.52",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.51",
|
||||
"version": "1.89.52",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
|
||||
@@ -984,6 +984,21 @@ function normalizePdfLapChart(chart) {
|
||||
return { title: String(chart.title || "").slice(0, 80), lapLabel: String(chart.lapLabel || "").slice(0, 20), laps, series };
|
||||
}
|
||||
|
||||
// A heat's lap times: a row per lap, a column per driver (finish order), best laps marked.
|
||||
function normalizePdfLapTable(table) {
|
||||
if (!table || !Array.isArray(table.names) || !Array.isArray(table.rows)) return null;
|
||||
const names = table.names.slice(0, 24).map((name) => String(name || "-").slice(0, 60));
|
||||
if (!names.length) return null;
|
||||
const rows = table.rows.slice(0, 400).map((row) => names.map((_n, col) => String((Array.isArray(row) ? row[col] : "") ?? "").slice(0, 12)));
|
||||
if (!rows.length) return null;
|
||||
const index = (value, max) => { const n = Math.floor(Number(value)); return Number.isInteger(n) && n >= 0 && n < max ? n : -1; };
|
||||
const best = names.map((_n, col) => index(Array.isArray(table.best) ? table.best[col] : -1, rows.length));
|
||||
const fastest = table.fastest && index(table.fastest.row, rows.length) >= 0 && index(table.fastest.col, names.length) >= 0
|
||||
? { row: index(table.fastest.row, rows.length), col: index(table.fastest.col, names.length) }
|
||||
: null;
|
||||
return { title: String(table.title || "").slice(0, 80), lapLabel: String(table.lapLabel || "").slice(0, 20), legend: String(table.legend || "").slice(0, 160), names, rows, best, fastest };
|
||||
}
|
||||
|
||||
function normalizePdfExportPayload(input = {}) {
|
||||
const title = String(input.title || "RC RaceCore").trim();
|
||||
const subtitle = String(input.subtitle || "").trim();
|
||||
@@ -1006,6 +1021,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),
|
||||
lapTable: normalizePdfLapTable(section?.lapTable),
|
||||
}))
|
||||
: [];
|
||||
|
||||
|
||||
@@ -349,6 +349,55 @@ function drawLapChart(writer, chart) {
|
||||
writer.y -= height + 8;
|
||||
}
|
||||
|
||||
// The lap times under a heat: a row per lap, a column per driver in finish order. Each driver's
|
||||
// best lap is bold on green, the fastest lap of the heat bold on purple.
|
||||
const BEST_LAP_FILL = "#dcf5e3";
|
||||
const FASTEST_LAP_FILL = "#eadcfb";
|
||||
const FASTEST_LAP_TEXT = "#5b21b6";
|
||||
function drawLapTable(writer, table, theme) {
|
||||
const cols = table.names.length;
|
||||
const lapW = 24;
|
||||
const colW = (writer.width - lapW) / cols;
|
||||
const size = cols > 10 ? 6.5 : 7.5;
|
||||
const rowH = cols > 10 ? 11 : 12.5;
|
||||
const headLines = table.names.map((name, index) => wrapText(`${index + 1}. ${name}`, size, true, colW - 4).slice(0, 2));
|
||||
const headH = 6 + Math.max(1, ...headLines.map((lines) => lines.length)) * (size + 2.5);
|
||||
const baseline = (top) => top - rowH + (rowH - size) / 2 + 1.2;
|
||||
const drawHead = () => {
|
||||
writer.rect(MARGIN, writer.y - headH, writer.width, headH, theme.headFill);
|
||||
writer.text(MARGIN + 3, writer.y - 4 - size, fitText(table.lapLabel, size, true, lapW - 4), size, { bold: true, color: theme.headText });
|
||||
headLines.forEach((lines, col) => lines.forEach((line, index) => {
|
||||
writer.text(MARGIN + lapW + col * colW + 2, writer.y - 4 - size - index * (size + 2.5), line, size, { bold: true, color: theme.headText, align: "center", width: colW - 4 });
|
||||
}));
|
||||
writer.y -= headH;
|
||||
};
|
||||
writer.ensure(18 + headH + rowH * 3);
|
||||
writer.text(MARGIN, writer.y - 10, fitText(table.title, 10, true, writer.width), 10, { bold: true });
|
||||
writer.y -= 16;
|
||||
drawHead();
|
||||
table.rows.forEach((row, rowIndex) => {
|
||||
if (writer.ensure(rowH)) drawHead();
|
||||
const top = writer.y;
|
||||
if (rowIndex % 2 === 1) writer.rect(MARGIN, top - rowH, writer.width, rowH, theme.zebra);
|
||||
writer.text(MARGIN + 3, baseline(top), String(rowIndex + 1), size, { color: MUTED });
|
||||
row.forEach((value, col) => {
|
||||
const x = MARGIN + lapW + col * colW;
|
||||
const fastest = Boolean(table.fastest && table.fastest.row === rowIndex && table.fastest.col === col);
|
||||
const best = table.best[col] === rowIndex;
|
||||
if (fastest || best) writer.rect(x + 1, top - rowH + 0.6, colW - 2, rowH - 1.2, fastest ? FASTEST_LAP_FILL : BEST_LAP_FILL);
|
||||
writer.text(x + 2, baseline(top), fitText(value, size, fastest || best, colW - 4), size, { bold: fastest || best, color: fastest ? FASTEST_LAP_TEXT : TEXT, align: "center", width: colW - 4 });
|
||||
});
|
||||
writer.line(MARGIN, top - rowH, MARGIN + writer.width, top - rowH, RULE, 0.3);
|
||||
writer.y -= rowH;
|
||||
});
|
||||
if (table.legend) {
|
||||
writer.ensure(14);
|
||||
writer.text(MARGIN, writer.y - 9, fitText(table.legend, 7, false, writer.width), 7, { color: MUTED });
|
||||
writer.y -= 14;
|
||||
}
|
||||
writer.y -= 6;
|
||||
}
|
||||
|
||||
function drawParagraphs(writer, section) {
|
||||
section.rows.forEach((row) => row.forEach((value) => {
|
||||
wrapText(value, 10, false, writer.width).forEach((line) => {
|
||||
@@ -490,6 +539,7 @@ function buildStyledPdf(payload) {
|
||||
if (section.headers.length) drawTable(writer, section, theme);
|
||||
else drawParagraphs(writer, section);
|
||||
if (section.chart) drawLapChart(writer, section.chart);
|
||||
if (section.lapTable) drawLapTable(writer, section.lapTable, theme);
|
||||
});
|
||||
drawFooters(writer, pages, payload, theme, pageWidth);
|
||||
|
||||
|
||||
+18
-3
@@ -204,14 +204,20 @@ const getOverviewHeats = (event, onlySessionId = "") => [...(getRaceOverview(eve
|
||||
})
|
||||
.filter(({ session }) => !onlySessionId || session.id === onlySessionId);
|
||||
// The lap chart prints with a single heat, and with the finals in the full results.
|
||||
const renderRaceOverviewHeatsHtml = (event, onlySessionId = "") => getOverviewHeats(event, onlySessionId).map(({ session, rows, phase, lapChart }) => `
|
||||
// Lap times under a single heat: a column per driver in finish order, best laps marked.
|
||||
const renderPrintLapTable = (table) => `<div class="print-lap-table"><h3>${escapeHtml(t("lap_table.title"))}</h3><table><thead><tr><th>${escapeHtml(t("table.lap"))}</th>${table.names.map((name, index) => `<th>${index + 1}. ${escapeHtml(name)}</th>`).join("")}</tr></thead><tbody>${table.rows.map((row, rowIndex) => `<tr><td>${rowIndex + 1}</td>${row.map((ms, col) => {
|
||||
const cls = table.fastest && table.fastest.row === rowIndex && table.fastest.col === col ? "lap-fastest" : table.best[col] === rowIndex ? "lap-best" : "";
|
||||
return `<td${cls ? ` class="${cls}"` : ""}>${ms ? escapeHtml(formatLap(ms).replace(/^0:/, "")) : ""}</td>`;
|
||||
}).join("")}</tr>`).join("")}</tbody></table><p class="hint">${escapeHtml(t("lap_table.legend"))}</p></div>`;
|
||||
const renderRaceOverviewHeatsHtml = (event, onlySessionId = "") => getOverviewHeats(event, onlySessionId).map(({ session, rows, phase, lapChart, lapTable }) => `
|
||||
<section class="print-block">
|
||||
<h2>${escapeHtml(raceOverviewPhaseLabel(phase.type))} • ${escapeHtml(session.name)}</h2>
|
||||
${renderTable([t("table.pos"), ...(rows.some((row) => row.qual) ? [t("table.qual")] : []), t("table.driver"), ...(rows.some((row) => row.car) ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
rows.map((row) => `<tr><td>${medal(row.pos)}</td>${rows.some((item) => item.qual) ? qualCell(row.qual, escapeHtml) : ""}<td>${rowFlag(row)}${escapeHtml(row.name)}</td>${rows.some((item) => item.car) ? `<td>${escapeHtml(row.car || "-")}</td>` : ""}<td>${row.laps}</td><td>${escapeHtml(row.result)}</td><td>${row.bestLapMs ? escapeHtml(formatLap(row.bestLapMs)) : "-"}</td></tr>`))}
|
||||
${lapChart && (onlySessionId || phase.type === "final") ? `<div class="print-lap-chart"><h3>${escapeHtml(t("lap_chart.title"))}</h3>${renderLapChartSvg(lapChart, { escapeHtml, title: t("lap_chart.title"), lapLabel: t("table.lap") })}</div>` : ""}
|
||||
${lapTable && onlySessionId ? renderPrintLapTable(lapTable) : ""}
|
||||
</section>`).join("");
|
||||
const buildHeatPdfSection = ({ session, rows, phase, lapChart }, { withChart = true } = {}) => {
|
||||
const buildHeatPdfSection = ({ session, rows, phase, lapChart, lapTable }, { withChart = true } = {}) => {
|
||||
const withCar = rows.some((row) => row.car);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
const section = buildPdfSection(
|
||||
@@ -220,7 +226,12 @@ const buildHeatPdfSection = ({ session, rows, phase, lapChart }, { withChart = t
|
||||
rows.map((row) => [String(row.pos), ...(withQual ? [row.qual || "-"] : []), row.name, ...(withCar ? [row.car || "-"] : []), String(row.laps), row.result, row.bestLapMs ? formatLap(row.bestLapMs) : "-"]),
|
||||
pdfFlags(rows)
|
||||
);
|
||||
return lapChart && withChart ? { ...section, chart: { title: t("lap_chart.title"), lapLabel: t("table.lap"), ...lapChart } } : section;
|
||||
const withLapChart = lapChart && withChart ? { ...section, chart: { title: t("lap_chart.title"), lapLabel: t("table.lap"), ...lapChart } } : section;
|
||||
// The lap times (a column per driver, best laps marked) only with a single heat's PDF.
|
||||
const shortLap = (ms) => (ms ? formatLap(ms).replace(/^0:/, "") : "");
|
||||
return lapTable && withChart
|
||||
? { ...withLapChart, lapTable: { title: t("lap_table.title"), lapLabel: t("table.lap"), names: lapTable.names, rows: lapTable.rows.map((row) => row.map(shortLap)), best: lapTable.best, fastest: lapTable.fastest, legend: t("lap_table.legend") } }
|
||||
: withLapChart;
|
||||
};
|
||||
// One finished heat or final on its own page: for the board in the pits right after it.
|
||||
const printHeatResult = (event, sessionId) => {
|
||||
@@ -2587,6 +2598,8 @@ const TRANSLATIONS = {
|
||||
"events.practice_seed_laps_hint": "Hur practice-heaten rankas inför kvalet. 0 = bästa enskilda varv. 3 med Bästa N konsekutiva varv = EFRA-seedning (3 snabbaste varv i rad). Gäller även redan körd practice – rankingen räknas om från varven.",
|
||||
"events.practice_seed_method": "Practice-seedning: metod",
|
||||
"seed.in_a_row": "{n} i rad",
|
||||
"lap_table.title": "Varvtider",
|
||||
"lap_table.legend": "Fet = förarens bästa varv · lila = heatets snabbaste varv",
|
||||
"seed.average": "snitt {n}",
|
||||
"seed.best_sum": "{n} bästa",
|
||||
"events.practice_seed_method_hint": "Hur varven räknas när antal varv är över 0.",
|
||||
@@ -5037,6 +5050,8 @@ const TRANSLATIONS = {
|
||||
"events.practice_seed_laps_hint": "How the practice heats are ranked before qualifying. 0 = best single lap. 3 with Best N consecutive laps = EFRA seeding (3 fastest laps in a row). Also applies to practice already run – the ranking is worked out again from the laps.",
|
||||
"events.practice_seed_method": "Practice seeding: method",
|
||||
"seed.in_a_row": "{n} in a row",
|
||||
"lap_table.title": "Lap times",
|
||||
"lap_table.legend": "Bold = the driver's best lap · purple = the fastest lap of the heat",
|
||||
"seed.average": "avg {n}",
|
||||
"seed.best_sum": "best {n}",
|
||||
"events.practice_seed_method_hint": "How the laps are counted when the number of laps is above 0.",
|
||||
|
||||
@@ -30,6 +30,24 @@ export function buildLapChart(entries = []) {
|
||||
};
|
||||
}
|
||||
|
||||
// Lap times table under a heat: a row per lap, a column per driver in finish order.
|
||||
// entries: [{ name, laps: [lapMs, ...] }]. Returns { names, rows: [[lapMs | null per driver]],
|
||||
// best: [row index of each driver's best lap | -1], fastest: { row, col } | null } or null.
|
||||
export function buildLapTable(entries = []) {
|
||||
const drivers = entries.slice(0, LAP_CHART_MAX_DRIVERS)
|
||||
.map((entry) => ({ name: String(entry?.name || "-"), laps: (entry?.laps || []).map(Number).filter((ms) => Number.isFinite(ms) && ms > 0).slice(0, LAP_CHART_MAX_LAPS) }));
|
||||
const count = Math.max(0, ...drivers.map((driver) => driver.laps.length));
|
||||
if (!count || !drivers.some((driver) => driver.laps.length)) return null;
|
||||
const rows = Array.from({ length: count }, (_, lap) => drivers.map((driver) => driver.laps[lap] ?? null));
|
||||
const best = drivers.map((driver) => (driver.laps.length ? driver.laps.indexOf(Math.min(...driver.laps)) : -1));
|
||||
let fastest = null;
|
||||
best.forEach((row, col) => {
|
||||
if (row < 0) return;
|
||||
if (!fastest || drivers[col].laps[row] < rows[fastest.row][fastest.col]) fastest = { row, col };
|
||||
});
|
||||
return { names: drivers.map((driver) => driver.name), rows, best, fastest };
|
||||
}
|
||||
|
||||
// Which lap numbers get a tick: about 10 along the axis, always the last.
|
||||
export function lapChartTicks(laps) {
|
||||
const step = laps <= 12 ? 1 : laps <= 30 ? 2 : laps <= 60 ? 5 : laps <= 150 ? 10 : 25;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Race overview (Race Day): the whole event in one place - podium, then practice, qualifying
|
||||
// and finals, each with its standings and every heat's result. Also the rows for one CSV.
|
||||
// Works for race events and sponsor events (their heats carry carAssignments).
|
||||
import { buildLapChart } from "./lap_chart_logic.js";
|
||||
import { buildLapChart, buildLapTable } from "./lap_chart_logic.js";
|
||||
const PHASES = ["practice", "qualification", "final"];
|
||||
|
||||
// Where each driver ended up in qualifying ("TQ" for the top qualifier), shown next to the
|
||||
@@ -40,9 +40,14 @@ export function buildRaceOverview(event, deps) {
|
||||
const lapChart = type !== "practice" && getCompetitorPassings
|
||||
? buildLapChart(leaderboard.map((row) => ({ name: row.displayName || row.driverName || row.transponder || "-", timestamps: getCompetitorPassings(session, row).map((passing) => passing.timestamp) })))
|
||||
: null;
|
||||
// Every lap time per driver, in finish order (printed under a single heat).
|
||||
const lapTable = getCompetitorPassings
|
||||
? buildLapTable(leaderboard.map((row) => ({ name: row.displayName || row.driverName || row.transponder || "-", laps: getCompetitorPassings(session, row).map((passing) => passing.lapMs) })))
|
||||
: null;
|
||||
return {
|
||||
session,
|
||||
lapChart,
|
||||
lapTable,
|
||||
rows: leaderboard.map((row, index) => ({
|
||||
pos: index + 1,
|
||||
driverId: row.driverId,
|
||||
|
||||
@@ -5159,3 +5159,9 @@ tr.is-selected td { background: color-mix(in srgb, var(--danger) 12%, transparen
|
||||
.qual-start-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 8px; }
|
||||
.qual-start-form label { display: grid; gap: 4px; font-size: 0.85rem; }
|
||||
.qual-start-form input[type="time"] { width: auto; }
|
||||
.print-lap-table { margin-top: 12px; }
|
||||
.print-lap-table table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
|
||||
.print-lap-table th, .print-lap-table td { padding: 2px 4px; text-align: center; border-bottom: 1px solid #d8dde6; }
|
||||
.print-lap-table td:first-child, .print-lap-table th:first-child { text-align: left; color: #6b7486; }
|
||||
.print-lap-table .lap-best { background: #dcf5e3; font-weight: 700; }
|
||||
.print-lap-table .lap-fastest { background: #eadcfb; color: #5b21b6; font-weight: 700; }
|
||||
@@ -62,3 +62,21 @@ test("the PDF draws the lap chart as coloured lines with the names", () => {
|
||||
assert.ok(pdf.includes("(1. Anna) Tj") && pdf.includes("(2. Bo) Tj"));
|
||||
assert.ok(pdf.includes("0.902 0.224 0.275 RG"), "the first driver's red line");
|
||||
});
|
||||
|
||||
test("lap table: a column per driver in order, each driver's best lap and the heat's fastest", async () => {
|
||||
const { buildLapTable } = await import("../src/lap_chart_logic.js");
|
||||
const table = buildLapTable([{ name: "A", laps: [18000, 17500, 17900] }, { name: "B", laps: [17400, 18100] }]);
|
||||
assert.deepEqual(table.names, ["A", "B"]);
|
||||
assert.deepEqual(table.rows, [[18000, 17400], [17500, 18100], [17900, null]]);
|
||||
assert.deepEqual(table.best, [1, 0]);
|
||||
assert.deepEqual(table.fastest, { row: 0, col: 1 });
|
||||
assert.equal(buildLapTable([{ name: "A", laps: [] }]), null);
|
||||
});
|
||||
|
||||
test("lap table: the PDF draws the times with the best laps bold", () => {
|
||||
const lapTable = { title: "Varvtider", lapLabel: "Varv", legend: "Fet = bästa", names: ["Anna", "Bo"], rows: [["17.400", "18.100"], ["17.900", "17.600"]], best: [0, 1], fastest: { row: 0, col: 0 } };
|
||||
const pdf = buildStyledPdf({ title: "R", subtitle: "", brandName: "K", brandTagline: "", footer: "", theme: "classic", logoDataUrl: "", sections: [{ title: "Q1 H1", headers: ["Pos", "Förare"], rows: [["1", "Anna"], ["2", "Bo"]], lapTable }] }).toString("latin1");
|
||||
assert.match(pdf, /Varvtider/);
|
||||
assert.match(pdf, /\/F2 [\d.]+ Tf [\d.]+ [\d.]+ Td \(17\.400\)/, "fastest lap in bold");
|
||||
assert.match(pdf, /\/F1 [\d.]+ Tf [\d.]+ [\d.]+ Td \(18\.100\)/, "an ordinary lap in regular");
|
||||
});
|
||||
Reference in new issue
Block a user