Function: teamColorScale()
teamColorScale<
T>(league,teams,o?):G2ColorScale<T>
Defined in: packages/sdvplot/src/g2.ts:92
Team colours as a G2 scale.color ({ type: "ordinal", domain, range }): the mark's encode.color field holds the
team values, and each draws in its own colour; the legend lists the teams in this order. With background the
colours read on it (dark mode). Pass the teams as the data holds them: G2 matches the domain to the data by exact
value, so a numeric id stays a number here (12, not "12"); a value given twice (also 12 and "12") is kept once.
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?
G2ColorOptions = {}
Returns
G2ColorScale<T>
Example
import { loadLeague } from "@sportsdataverse/sdvplot";
import { teamColorScale } from "@sportsdataverse/sdvplot/g2";
await loadLeague("nfl");
// { type: "interval", encode: { x: "team", y: "wins", color: "team" }, scale: { color: <this> } }
teamColorScale("nfl", ["KC", "LAC", "DEN", "LV"]);