Skip to main content

Function: teamColorGetter()

teamColorGetter(league, teams, o?): (d) => string

Defined in: packages/sdvplot/src/mui.ts:140

A colour per data point, for a series' colorGetter (bar, scatter, line): teams[i] is the team of data point i, so each bar or point takes its own team's colour. A team that repeats keeps one colour. With background, every colour keeps 3:1 contrast against it (dark mode). A point past the end of teams takes fallback.

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 unknown[]

o?​

MuiColorOptions = {}

Returns​

(d) => string

Example​

import { BarChart } from "@mui/x-charts/BarChart";
import { loadLeague } from "@sportsdataverse/sdvplot";
import { teamColorGetter } from "@sportsdataverse/sdvplot/mui";

await loadLeague("nfl");
const teams = ["KC", "BUF", "BAL"];
<BarChart
width={400}
height={240}
xAxis={[{ scaleType: "band", data: teams }]}
series={[{ data: [15, 13, 12], colorGetter: teamColorGetter("nfl", teams) }]}
/>;