Skip to main content

Function: teamChartConfig()

teamChartConfig(league, teams, o?): TeamChartConfig

Defined in: packages/sdvplot/src/shadcn.ts:131

shadcn's ChartConfig for teams: one entry per team, keyed for CSS (team names like "Trail Blazers" are not valid custom property names), with the team's name as label, its colour on shadcn's light and dark backgrounds as theme (3:1 contrast on each, and distinct from the other teams'), and its logo as icon, which <ChartLegendContent> and <ChartTooltipContent> draw in place of their colour swatch. A team with no logo has no icon (shadcn falls back to the swatch) and warns once. The icons are the same components for the same logo on every call, so building the config inside a component's render is safe.

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

TeamChartConfigOptions = {}

Returns​

TeamChartConfig

Example​

import { loadLeague } from "@sportsdataverse/sdvplot";
import { teamChartConfig } from "@sportsdataverse/sdvplot/shadcn";

await loadLeague("nba");
// "Trail Blazers" is not a CSS name: its key is "trail-blazers", a series' dataKey and var(--color-trail-blazers)
const { config, keys } = teamChartConfig("nba", ["Trail Blazers", "Lakers"]);
[keys, config["trail-blazers"]?.label, config["trail-blazers"]?.theme];