Skip to main content

stackTables: tables one above the other (gt_stack_tables)

AFC, 2024
TeamQuarterbackWinsLosses
KCPatrick Mahomes152
LACJustin Herbert116
DENBo Nix107
LVGardner Minshew413
TeamQuarterbackWinsLosses
BUFJosh Allen134
MIATua Tagovailoa89
NYJAaron Rodgers512
NEDrake Maye413

West above, East below

Source: nflverse

import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { stackTables } from "@sportsdataverse/sdvtables/export";

const spec = defineTable<Standing>()
.columns((c) => [c.text("team"), c.text("qb", { label: "Quarterback" }), c.int("wins"), c.int("losses")])
.theme("pl")
.build();
// one spec used twice: each copy gets its own id, so each keeps its decorations
stackTables(
[
{ spec, rows: STANDINGS.filter((r) => r.division === "West") },
{ spec, rows: STANDINGS.filter((r) => r.division === "East") },
],
{ title: "AFC, 2024", caption: "West above, East below", sourceNote: "Source: nflverse" },
);

Tags: node · table · export · stackTables · nfl. All sdvtables examples.