Skip to main content

AFC quarterbacks on a dark theme: headshots, a spotlight and division accents

NFL 2024
Josh Allen's Bills, and the rest of the AFC East and WestStarting quarterback, record, league-wide SRS rank and net EPA per play; East rows edged blue, West amber
3918298
Josh Allen
BUF
13-44th0.190L
4426338
Bo Nix
DEN
10-78th0.108W
4038941
Justin Herbert
LAC
11-69th0.101W
3139477
Patrick Mahomes
KC
15-210th0.063L
4241479
Tua Tagovailoa
MIA
8-921st-0.019L
8439
Aaron Rodgers
NYJ
5-1224th-0.045W
4038524
Gardner Minshew
LV
4-1326th-0.146L
4431452
Drake Maye
NE
4-1329thW
Source: nflverse games, players and play_by_play_2024. New England's net EPA is blanked in the sample data.
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { createTable, defineTable } from "@sportsdataverse/sdvtables";
import { hydrate, prepare, renderHTML } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<Standing>()
.columns((c) => [
c.headshot("qb_espn_id", { league: "nfl", label: "", sortable: false }),
// color: the top line, black by default, in midnight's text colour
c.mergeStackTeamColor("qb", "team", "team", { league: "nfl", label: "Quarterback", color: "#E8E9ED" }),
c.text("division"),
c.tally(["wins", "losses"], { label: "W-L" }),
c.rank("srs_rank", { label: "SRS rank" }),
c.colorPills("net_epa", { label: "Net EPA/play", digits: 3, domain: [-0.2, 0.2], naColor: "#3A3D45" }),
c.text("result_last", { label: "Week 18", align: "center" }),
])
// the division column becomes a coloured left edge (and is hidden); Buffalo is lit, the rest dimmed
.rowAccent("division", { palette: { East: "#5B8DEF", West: "#E8A33D" }, width: 5 })
.spotlight({ key: "team", op: "==", value: "BUF" }, { accentColor: "#C60C30" })
.titleHeader("Josh Allen's Bills, and the rest of the AFC East and West", {
kicker: "NFL 2024",
subtitle:
"Starting quarterback, record, league-wide SRS rank and net EPA per play; East rows edged blue, West amber",
})
.sourceNote(
"Source: nflverse games, players and play_by_play_2024. New England's net EPA is blanked in the sample data.",
)
.theme("midnight")
.rowKey("team")
.build();
await prepare(spec);
const table = createTable(spec, STANDINGS, { sort: { col: "srs_rank", dir: "asc" } });
const host = document.createElement("div");
host.innerHTML = renderHTML(table);
hydrate(host.querySelector(".sdvt") as Element, table);
host;

Tags: table · recipe · interactive · midnight · headshot · mergeStackTeamColor · colorPills · spotlight · rowAccent · nfl. All sdvtables examples.