leaguesOf and columnLabel: what a spec needs and shows
{
"leaguesOf(teams)": [
"nfl"
],
"leaguesOf(players)": [],
"teams.columns.map(columnLabel)": [
"Team",
"Wins",
"Net EPA/play"
],
"players.columns.map(columnLabel)": [
"Qb Espn Id",
"Qb"
]
}import type { Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { columnLabel, leaguesOf } from "@sportsdataverse/sdvtables/html";
// leaguesOf lists the league shards prepare() will load: team-aware columns and the sdvTeam theme.
// ESPN headshot URLs are built from the id alone, so a headshot column needs none.
const teams = defineTable<Standing>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.int("wins"),
c.num("net_epa", { label: "Net EPA/play" }),
])
.build();
const players = defineTable<Standing>()
.columns((c) => [c.headshot("qb_espn_id", { league: "nfl" }), c.text("qb")])
.build();
{
"leaguesOf(teams)": leaguesOf(teams),
"leaguesOf(players)": leaguesOf(players),
// a label falls back to the key, title-cased
"teams.columns.map(columnLabel)": teams.columns.map(columnLabel),
"players.columns.map(columnLabel)": players.columns.map(columnLabel),
};
Tags: table · leaguesOf · columnLabel · prepare. All sdvtables examples.