Skip to main content

Function: teamColorScale()

teamColorScale<T>(league, teams, o?): TanstackColorScale<T>

Defined in: packages/sdvplot/src/tanstack.ts:90

Team colours as TanStack's chart color option: { domain, range }, which TanStack maps by position, so the team in a mark's color (or z) channel draws in its own colour and the legend lists the teams in this order. Spread it and add a legend if wanted. With background the colours read on it (dark mode). TanStack matches a value by its type as well (12 and "12" are two keys): pass the teams as the data holds them. A value given twice is kept once; 12 and "12" are both kept, with one colour.

Type Parameters​

T​

T

Parameters​

league​

"aaf" | "ahl" | "ajhl" | "bchl" | "cchl" | "cebl" | "cfb" | "cfl" | "chl" | "cricket" | "easl" | "echl" | "f1" | "fiba" | "gojhl" | "iihf" | "kijhl" | "lba" | "mbb" | "mhl" | "milb" | "mjhl" | "mlb" | "nba" | "nbagl" | "nbl" | "ncaa_baseball" | "ncaa_mhockey" | "ncaa_softball" | "ncaa_whockey" | "nfl" | "nhl" | "nojhl" | "ohl" | "ojhl" | "phf" | "pwhl" | "qmjhl" | "sjhl" | "soccer" | "sphl" | "ufl" | "usfl" | "ushl" | "vijhl" | "wbb" | "whl" | "wnba" | "xfl"

teams​

readonly T[]

o?​

TanstackColorOptions = {}

Returns​

TanstackColorScale<T>

Example​

import { loadLeague } from "@sportsdataverse/sdvplot";
import { teamColorScale } from "@sportsdataverse/sdvplot/tanstack";

await loadLeague("nfl");
// defineChart({ marks: [lineY(rows, { x: "week", y: "margin", z: "team" })], color: <this> })
teamColorScale("nfl", ["KC", "LAC", "DEN", "LV"], { background: "#111827" });