Skip to main content

gridTables by a group column: the Super Bowl LIX teams' seasons, side by side

Before Super Bowl LIX

Every 2024 regular-season game of the two finalists

Kansas City, 15-2
WkOpp.Score
127-20W
226-25W
322-17W
417-10W
526-13W
728-18W
827-20W
930-24W
1016-14W
1121-30L
1230-27W
1319-17W
1419-17W
1521-7W
1627-19W
1729-10W
180-38L
Philadelphia, 14-3
WkOpp.Score
134-29W
221-22L
315-12W
416-33L
620-16W
728-3W
837-17W
928-23W
1034-6W
1126-18W
1237-20W
1324-19W
1422-16W
1527-13W
1633-36L
1741-7W
1820-13W

Source: nflverse games

import { KC_PHI_GAMES_2024 } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { gridTables } from "@sportsdataverse/sdvtables/export";
import { prepare } from "@sportsdataverse/sdvtables/html";

// Each game from each team's side, then one table per team: the grouping batchToPNG writes as one file per team,
// laid out here on one page instead.
const games = (team: "KC" | "PHI") =>
KC_PHI_GAMES_2024.filter((g) => g.home_team === team || g.away_team === team).map((g) => {
const home = g.home_team === team;
const pts = home ? g.home_score : g.away_score;
const opp = home ? g.away_score : g.home_score;
return {
week: g.week,
opponent: home ? g.away_team : g.home_team,
score: `${pts}-${opp}`,
result: pts > opp ? "W" : "L",
};
});
const spec = defineTable<ReturnType<typeof games>[number]>()
.columns((c) => [
c.int("week", { label: "Wk" }),
c.logo("opponent", { league: "nfl", label: "Opp." }),
c.text("score", { label: "Score" }),
c.colorResults("result", { label: "" }),
])
.theme("athletic", { density: "compact" })
.build();
await prepare(spec);
// one spec, two tables: each copy gets its own id, so each keeps its own styles
gridTables(
[
{ spec, rows: games("KC") },
{ spec, rows: games("PHI") },
],
{
ncol: 2,
gap: 40,
labels: ["Kansas City, 15-2", "Philadelphia, 14-3"],
title: "Before Super Bowl LIX",
subtitle: "Every 2024 regular-season game of the two finalists",
sourceNote: "Source: nflverse games",
},
);

Tags: node · table · export · gridTables · colorResults · logo · nfl. All sdvtables examples.