feat(results): lap chart per qualifying heat and final in the race overview, print and PDF (1.89.32)
This commit is contained in:
1 parent
01998952a7
commit
6a036899ab
15 files changed
+245
-14
No files matched your search
+13
-5
@@ -15,6 +15,7 @@ import { flagHtml, driverCountryCode, countryChoices, setDriverCountryResolver,
|
||||
import { renderRaceDayView, refreshRaceDayWarmup, refreshRaceDayPrologueClock, updateRaceDayStartDisplay, refreshRaceDayLive } from "./race_day_view.js";
|
||||
import { assignMarshals, normalizeRaceDays, getRaceDay, upsertRaceDay, orderDaySessions, buildDaySchedule, getAutopilotAction, moveInDayOrder, pickBoardDate, getDueCall, withRaceSetupStart, eventScheduleFromDayRows } from "./day_schedule_logic.js";
|
||||
import { buildRaceOverview, buildRaceOverviewCsvRows, withQualifyingPlaces, qualifyingPlaces } from "./race_overview_logic.js";
|
||||
import { renderLapChartSvg } from "./lap_chart_logic.js";
|
||||
import { renderRaceOverviewPanel, bindRaceOverviewPanel } from "./race_overview_view.js";
|
||||
import { renderSpeakerPanel, bindSpeakerPanel } from "./speaker_panel_view.js";
|
||||
import { renderDaySchedulePanel, bindDaySchedulePanel, buildDaySchedulePrintHtml, renderDriverBoard, formatClockTime, renderDayCallBanner, bindDayCallBanner } from "./day_schedule_view.js";
|
||||
@@ -167,7 +168,7 @@ const buildPrintBrandBlock = (branding) => buildPrintBrandBlockHelper(branding,
|
||||
const buildRaceStartListsHtml = (event) => buildRaceStartListsHtmlHelper(event, { t, state, escapeHtml, resolveEventBranding, getSessionsForEvent, getSessionSortWeight, getClassName, buildPrintBrandBlock, getSessionGridEntries, getSessionTypeLabel, getStartModeLabel, renderTable, buildEventSchedule });
|
||||
const buildRaceResultsHtml = (event) => buildRaceResultsHtmlHelper(event, { t, escapeHtml, resolveEventBranding, getClassName, buildPrintBrandBlock, renderRaceStandingsTableView, buildPracticeStandings, buildQualifyingStandings, buildFinalStandings, renderTeamRaceStandings, getSessionsForEvent, renderSessionChannelAnalysis, renderHeatResults: (event) => renderRaceOverviewHeatsHtml(event) });
|
||||
// Race overview (Race Day and the results archive): the whole race, with print, PDF and CSV.
|
||||
const getRaceOverview = (event) => buildRaceOverview(event, { sessions: getSessionsForEvent(event?.id), cars: state.cars, buildLeaderboard, buildPracticeStandings, buildQualifyingStandings, buildFinalStandings });
|
||||
const getRaceOverview = (event) => buildRaceOverview(event, { sessions: getSessionsForEvent(event?.id), cars: state.cars, buildLeaderboard, buildPracticeStandings, buildQualifyingStandings, buildFinalStandings, getCompetitorPassings });
|
||||
const raceOverviewPhaseLabel = (type) => t(`race_overview.phase_${type}`);
|
||||
const renderRaceOverviewFor = (event) => (event ? renderRaceOverviewPanel(getRaceOverview(event), { t, escapeHtml, formatLap, renderTable, renderRaceStandingsTableView, phaseLabel: raceOverviewPhaseLabel, getStatusLabel }) : "");
|
||||
const bindRaceOverviewFor = (root, event) => event && bindRaceOverviewPanel(root, getRaceOverview(event), {
|
||||
@@ -190,21 +191,24 @@ const getOverviewHeats = (event, onlySessionId = "") => [...(getRaceOverview(eve
|
||||
return heats.map((heat) => ({ ...heat, phase }));
|
||||
})
|
||||
.filter(({ session }) => !onlySessionId || session.id === onlySessionId);
|
||||
const renderRaceOverviewHeatsHtml = (event, onlySessionId = "") => getOverviewHeats(event, onlySessionId).map(({ session, rows, phase }) => `
|
||||
// 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 }) => `
|
||||
<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>` : ""}
|
||||
</section>`).join("");
|
||||
const buildHeatPdfSection = ({ session, rows, phase }) => {
|
||||
const buildHeatPdfSection = ({ session, rows, phase, lapChart }, { withChart = true } = {}) => {
|
||||
const withCar = rows.some((row) => row.car);
|
||||
const withQual = rows.some((row) => row.qual);
|
||||
return buildPdfSection(
|
||||
const section = buildPdfSection(
|
||||
`${raceOverviewPhaseLabel(phase.type)} • ${session.name}`,
|
||||
[t("table.pos"), ...(withQual ? [t("table.qual")] : []), t("table.driver"), ...(withCar ? [t("race_overview.car")] : []), t("table.laps"), t("table.result"), t("table.best_lap")],
|
||||
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;
|
||||
};
|
||||
// One finished heat or final on its own page: for the board in the pits right after it.
|
||||
const printHeatResult = (event, sessionId) => {
|
||||
@@ -3268,6 +3272,8 @@ const TRANSLATIONS = {
|
||||
"race_overview.standings": "Ställning",
|
||||
"race_overview.heats_done": "{done} av {total} heat klara",
|
||||
"race_overview.no_results": "Inga resultat än.",
|
||||
"lap_chart.title": "Varvdiagram",
|
||||
"lap_chart.hint": "Placering efter varje varv, räknat från passeringarna. Officiell placering står till höger.",
|
||||
"race_overview.not_run": "Inte körd än.",
|
||||
"race_overview.phase_practice": "Träning",
|
||||
"race_overview.phase_qualification": "Kval",
|
||||
@@ -5619,6 +5625,8 @@ const TRANSLATIONS = {
|
||||
"race_overview.standings": "Standings",
|
||||
"race_overview.heats_done": "{done} of {total} heats done",
|
||||
"race_overview.no_results": "No results yet.",
|
||||
"lap_chart.title": "Lap chart",
|
||||
"lap_chart.hint": "Place after every lap, counted from the passings. Official finish place on the right.",
|
||||
"race_overview.not_run": "Not run yet.",
|
||||
"race_overview.phase_practice": "Practice",
|
||||
"race_overview.phase_qualification": "Qualifying",
|
||||
@@ -8549,7 +8557,7 @@ async function buildRaceResultsPdfPayload(event) {
|
||||
buildPracticeStandings(event).map((row) => [String(row.rank), row.driverName || "-", row.score || "-"]),
|
||||
pdfFlags(buildPracticeStandings(event))
|
||||
),
|
||||
...getOverviewHeats(event).map(buildHeatPdfSection),
|
||||
...getOverviewHeats(event).map((heat) => buildHeatPdfSection(heat, { withChart: heat.phase.type === "final" })),
|
||||
...buildTeamRaceStandings(event).map(({ session, rows }) =>
|
||||
buildPdfSection(
|
||||
`${t("events.team_standings")} • ${session.name}`,
|
||||
|
||||
Reference in new issue
Block a user