Skip to main content

Function: teamColorScale()

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

Defined in: packages/sdvplot/src/unovis.ts:97

Team colours for Unovis's colour accessors: color(d.team) from a Graph's nodeFill, nodeStroke or linkStroke, a Sankey's nodeColor or linkColor, a Chord's nodeColor. Give every team the chart draws, so the colours are worked out together: with background they read on it (dark mode) and stay distinct. The domain keeps the values as the data holds them (12 and "12" are both kept); the colours are the resolved team's, so 12, "12" and "KC" draw in one colour. A value outside the domain gets fallback, with one warning.

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?​

UnovisColorOptions = {}

Returns​

UnovisTeamColorScale<T>

Example​

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

await loadLeague("nfl");
const color = teamColorScale("nfl", ["KC", "PHI"]);
// new Sankey({ linkColor: (l) => color(l.team), ... })
[color("KC"), color(21), color.range];