Function: teamColors()
teamColors(
league,teams,o?):MuiColorPalette
Defined in: packages/sdvplot/src/mui.ts:99
Team colours as a chart's colors, MUI's palette callback: MUI calls it with the theme's mode, so under a dark
ThemeProvider every series takes its team colour readable on the dark background (3:1 contrast, distinct from the
others), and under a light one readable on white. Series i takes teams[i]'s colour: give the series in the same
order. Each mode's palette is worked out once, when MUI first asks for it, so build it once (module scope or
useMemo): a new one on every render works the palettes out again.
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?
MuiPaletteOptions = {}
Returns
Example
import { createTheme, ThemeProvider } from "@mui/material/styles";
import { LineChart } from "@mui/x-charts/LineChart";
import { loadLeague } from "@sportsdataverse/sdvplot";
import { teamColors } from "@sportsdataverse/sdvplot/mui";
await loadLeague("nfl");
const teams = ["KC", "DEN"];
<ThemeProvider theme={createTheme({ palette: { mode: "dark" } })}>
<LineChart
width={400}
height={240}
colors={teamColors("nfl", teams)}
xAxis={[{ data: [1, 2, 3] }]}
series={[
{ id: "KC", data: [1, 2, 3] },
{ id: "DEN", data: [0, 1, 2] },
]}
/>
</ThemeProvider>;