@sportsdataverse/sdvplot 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +109 -0
- package/README.md +984 -2
- package/dist/_web-D7Aa5Rd8.d.ts +69 -0
- package/dist/aaf-GJ3SH34T.js +13 -0
- package/dist/aaf-HCYN5T6Y.js +37 -0
- package/dist/aaf-ZAE5KS2Y.js +13 -0
- package/dist/ahl-E66MDVCU.js +66 -0
- package/dist/ahl-NPQQWZEV.js +249 -0
- package/dist/ahl-QRDU73XX.js +309 -0
- package/dist/axis-CraWQRUJ.d.ts +49 -0
- package/dist/bins.d.ts +174 -0
- package/dist/bins.js +4 -0
- package/dist/bins.js.map +1 -0
- package/dist/cfb-F42SVS4X.js +5000 -0
- package/dist/cfb-P3SHEYRZ.js +692 -0
- package/dist/cfb-WXRZANLP.js +10226 -0
- package/dist/chartjs-surface.d.ts +42 -0
- package/dist/chartjs-surface.js +65 -0
- package/dist/chartjs-surface.js.map +1 -0
- package/dist/chartjs.d.ts +162 -0
- package/dist/chartjs.js +342 -0
- package/dist/chartjs.js.map +1 -0
- package/dist/chunk-4C3GX6QO.js +92 -0
- package/dist/chunk-4C3GX6QO.js.map +1 -0
- package/dist/chunk-57WFSI4Q.js +128 -0
- package/dist/chunk-57WFSI4Q.js.map +1 -0
- package/dist/chunk-7ULOCCFL.js +313 -0
- package/dist/chunk-7ULOCCFL.js.map +1 -0
- package/dist/chunk-AMXASQHT.js +120 -0
- package/dist/chunk-AMXASQHT.js.map +1 -0
- package/dist/chunk-B2MP37SR.js +175 -0
- package/dist/chunk-B2MP37SR.js.map +1 -0
- package/dist/chunk-C2CDY5OG.js +137 -0
- package/dist/chunk-C2CDY5OG.js.map +1 -0
- package/dist/chunk-DYMUVE6K.js +127 -0
- package/dist/chunk-DYMUVE6K.js.map +1 -0
- package/dist/chunk-E7G7VSLV.js +43 -0
- package/dist/chunk-E7G7VSLV.js.map +1 -0
- package/dist/chunk-H2C3FMMA.js +300 -0
- package/dist/chunk-H2C3FMMA.js.map +1 -0
- package/dist/chunk-J4P4HDBF.js +175 -0
- package/dist/chunk-J4P4HDBF.js.map +1 -0
- package/dist/chunk-J6R2LEJ7.js +58 -0
- package/dist/chunk-J6R2LEJ7.js.map +1 -0
- package/dist/chunk-M3XD2OSN.js +132 -0
- package/dist/chunk-M3XD2OSN.js.map +1 -0
- package/dist/chunk-OIILARXI.js +30 -0
- package/dist/chunk-OIILARXI.js.map +1 -0
- package/dist/chunk-RPVVJY74.js +170 -0
- package/dist/chunk-RPVVJY74.js.map +1 -0
- package/dist/chunk-UL5M6KDE.js +205 -0
- package/dist/chunk-UL5M6KDE.js.map +1 -0
- package/dist/chunk-WQT4IVLX.js +10 -0
- package/dist/chunk-WQT4IVLX.js.map +1 -0
- package/dist/chunk-ZAEQXFJM.js +556 -0
- package/dist/chunk-ZAEQXFJM.js.map +1 -0
- package/dist/cricket-KPCYG2HL.js +493 -0
- package/dist/cricket-NDXLE25B.js +116 -0
- package/dist/cricket-YUUF7P6M.js +160 -0
- package/dist/cytoscape.d.ts +188 -0
- package/dist/cytoscape.js +219 -0
- package/dist/cytoscape.js.map +1 -0
- package/dist/d3.d.ts +234 -0
- package/dist/d3.js +198 -0
- package/dist/d3.js.map +1 -0
- package/dist/deckgl.d.ts +232 -0
- package/dist/deckgl.js +197 -0
- package/dist/deckgl.js.map +1 -0
- package/dist/echarts.d.ts +121 -0
- package/dist/echarts.js +228 -0
- package/dist/echarts.js.map +1 -0
- package/dist/echl-3CR4RGFC.js +241 -0
- package/dist/echl-NPC32C23.js +107 -0
- package/dist/echl-PI33DGJC.js +64 -0
- package/dist/export.d.ts +130 -0
- package/dist/export.js +258 -0
- package/dist/export.js.map +1 -0
- package/dist/g2.d.ts +251 -0
- package/dist/g2.js +102 -0
- package/dist/g2.js.map +1 -0
- package/dist/headshots-B2J_LOO8.d.ts +40 -0
- package/dist/index.d.ts +183 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/interact.d.ts +567 -0
- package/dist/interact.js +809 -0
- package/dist/interact.js.map +1 -0
- package/dist/lightweight-charts.d.ts +217 -0
- package/dist/lightweight-charts.js +155 -0
- package/dist/lightweight-charts.js.map +1 -0
- package/dist/maplibre.d.ts +271 -0
- package/dist/maplibre.js +175 -0
- package/dist/maplibre.js.map +1 -0
- package/dist/marks-DH-tQIP-.d.ts +75 -0
- package/dist/mbb-3TRLVW3H.js +3619 -0
- package/dist/mbb-DQUHCHZP.js +5111 -0
- package/dist/mbb-PRAIO2P5.js +371 -0
- package/dist/milb-6IQ6NCEW.js +291 -0
- package/dist/milb-EYY5MD4T.js +1752 -0
- package/dist/milb-EYZ4SZLI.js +797 -0
- package/dist/mlb-4PBUJSVQ.js +35 -0
- package/dist/mlb-FHPY3GQJ.js +701 -0
- package/dist/mlb-REVGL3N2.js +665 -0
- package/dist/mui.d.ts +338 -0
- package/dist/mui.js +184 -0
- package/dist/mui.js.map +1 -0
- package/dist/nba-ATT775GS.js +485 -0
- package/dist/nba-LKM4UHVU.js +482 -0
- package/dist/nba-YX7PXM3R.js +35 -0
- package/dist/nbagl-3WGZCZ4S.js +37 -0
- package/dist/nbagl-LP4XJRAL.js +229 -0
- package/dist/nbagl-VTTOU7LN.js +499 -0
- package/dist/ncaa_baseball-UV75LNVR.js +2670 -0
- package/dist/ncaa_baseball-VD5J5C72.js +419 -0
- package/dist/ncaa_baseball-YRBS32D6.js +4592 -0
- package/dist/ncaa_mhockey-IMYHS7QS.js +1033 -0
- package/dist/ncaa_mhockey-TXTKWHE3.js +115 -0
- package/dist/ncaa_mhockey-U3MFW5VT.js +663 -0
- package/dist/ncaa_softball-6WR6KS64.js +420 -0
- package/dist/ncaa_softball-RZCTIE56.js +2654 -0
- package/dist/ncaa_softball-VOD4PVGY.js +4599 -0
- package/dist/ncaa_whockey-6XXGUTBK.js +607 -0
- package/dist/ncaa_whockey-AKKYKY67.js +53 -0
- package/dist/ncaa_whockey-KBEKXFBB.js +293 -0
- package/dist/nfl-BDB2HYAR.js +625 -0
- package/dist/nfl-EHYHDLJD.js +37 -0
- package/dist/nfl-VF4NJCHY.js +514 -0
- package/dist/nfl_gsis-UY64JO37.js +4 -0
- package/dist/nhl-6WPHME7H.js +511 -0
- package/dist/nhl-EMIJFZHY.js +884 -0
- package/dist/nhl-ISFUKRFU.js +37 -0
- package/dist/nivo.d.ts +193 -0
- package/dist/nivo.js +8 -0
- package/dist/nivo.js.map +1 -0
- package/dist/ohl-2FEM554G.js +113 -0
- package/dist/ohl-C5Q4W6JB.js +32 -0
- package/dist/ohl-TQ4J46VC.js +66 -0
- package/dist/perspective.d.ts +198 -0
- package/dist/perspective.js +171 -0
- package/dist/perspective.js.map +1 -0
- package/dist/phf-H7POU2KW.js +32 -0
- package/dist/phf-K5IFMZUM.js +13 -0
- package/dist/phf-TWJI3BOW.js +20 -0
- package/dist/placement-UWkqUzpa.d.ts +32 -0
- package/dist/plot.d.ts +451 -0
- package/dist/plot.js +712 -0
- package/dist/plot.js.map +1 -0
- package/dist/plotly.d.ts +129 -0
- package/dist/plotly.js +360 -0
- package/dist/plotly.js.map +1 -0
- package/dist/pwhl-OX3BO4JI.js +53 -0
- package/dist/pwhl-W44OC3C6.js +17 -0
- package/dist/pwhl-ZJGG3H7W.js +23 -0
- package/dist/qmjhl-5HISEHLL.js +35 -0
- package/dist/qmjhl-DA3UHKE5.js +125 -0
- package/dist/qmjhl-YG4BOQPF.js +614 -0
- package/dist/react.d.ts +377 -0
- package/dist/react.js +522 -0
- package/dist/react.js.map +1 -0
- package/dist/recharts.d.ts +162 -0
- package/dist/recharts.js +8 -0
- package/dist/recharts.js.map +1 -0
- package/dist/resolve-CQW-jzvr.d.ts +28 -0
- package/dist/selection-D4T3PkRt.d.ts +140 -0
- package/dist/shadcn.d.ts +83 -0
- package/dist/shadcn.js +88 -0
- package/dist/shadcn.js.map +1 -0
- package/dist/shots.d.ts +364 -0
- package/dist/shots.js +86 -0
- package/dist/shots.js.map +1 -0
- package/dist/soccer-7BH3ZLVL.js +7898 -0
- package/dist/soccer-MRU25OGE.js +2636 -0
- package/dist/soccer-PF4IPPVA.js +12342 -0
- package/dist/surface-TR7YFJW3.js +4 -0
- package/dist/surface-TR7YFJW3.js.map +1 -0
- package/dist/surfaces-MIG7HOFU.js +6 -0
- package/dist/surfaces-MIG7HOFU.js.map +1 -0
- package/dist/surfaces-W-odWLpT.d.ts +47 -0
- package/dist/svelte/HeadshotMark.svelte +25 -0
- package/dist/svelte/HeadshotMark.svelte.d.ts +10 -0
- package/dist/svelte/HeadshotMark.svelte.d.ts.map +1 -0
- package/dist/svelte/LogoMark.svelte +25 -0
- package/dist/svelte/LogoMark.svelte.d.ts +10 -0
- package/dist/svelte/LogoMark.svelte.d.ts.map +1 -0
- package/dist/svelte/Marks.svelte +25 -0
- package/dist/svelte/Marks.svelte.d.ts +10 -0
- package/dist/svelte/Marks.svelte.d.ts.map +1 -0
- package/dist/svelte/Surface.svelte +29 -0
- package/dist/svelte/Surface.svelte.d.ts +9 -0
- package/dist/svelte/Surface.svelte.d.ts.map +1 -0
- package/dist/svelte/SurfaceBackdrop.svelte +26 -0
- package/dist/svelte/SurfaceBackdrop.svelte.d.ts +11 -0
- package/dist/svelte/SurfaceBackdrop.svelte.d.ts.map +1 -0
- package/dist/svelte/index.d.ts +13 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +11 -0
- package/dist/svelte-core.d.ts +139 -0
- package/dist/svelte-core.js +123 -0
- package/dist/svelte-core.js.map +1 -0
- package/dist/tanstack.d.ts +240 -0
- package/dist/tanstack.js +110 -0
- package/dist/tanstack.js.map +1 -0
- package/dist/testing.d.ts +75 -0
- package/dist/testing.js +239 -0
- package/dist/testing.js.map +1 -0
- package/dist/three.d.ts +223 -0
- package/dist/three.js +50 -0
- package/dist/three.js.map +1 -0
- package/dist/tiers-BN4md-GB.d.ts +65 -0
- package/dist/types-C7n6gJF3.d.ts +62 -0
- package/dist/ufl-7VLZTLTT.js +143 -0
- package/dist/ufl-CCMBLPSW.js +100 -0
- package/dist/ufl-F2BJRXME.js +16 -0
- package/dist/unovis.d.ts +127 -0
- package/dist/unovis.js +108 -0
- package/dist/unovis.js.map +1 -0
- package/dist/uplot.d.ts +120 -0
- package/dist/uplot.js +110 -0
- package/dist/uplot.js.map +1 -0
- package/dist/usfl-4CR5RMZJ.js +32 -0
- package/dist/usfl-LD7HP2YK.js +14 -0
- package/dist/usfl-VU4YSJQD.js +19 -0
- package/dist/ushl-CPG2LB4L.js +73 -0
- package/dist/ushl-PQL6HJAD.js +88 -0
- package/dist/ushl-ZT2ATPHK.js +22 -0
- package/dist/vega.d.ts +85 -0
- package/dist/vega.js +362 -0
- package/dist/vega.js.map +1 -0
- package/dist/victory.d.ts +107 -0
- package/dist/victory.js +38 -0
- package/dist/victory.js.map +1 -0
- package/dist/wbb-3KHCDYTK.js +5087 -0
- package/dist/wbb-BMX53Q3Q.js +369 -0
- package/dist/wbb-QNRN2CJJ.js +3620 -0
- package/dist/whl-4ATYZWUB.js +97 -0
- package/dist/whl-RVFPL6MH.js +79 -0
- package/dist/whl-Y7ASKYMM.js +28 -0
- package/dist/wnba-FWX5SFVI.js +232 -0
- package/dist/wnba-GX6HZR4B.js +220 -0
- package/dist/wnba-NTMWIPP6.js +20 -0
- package/dist/xfl-43R2JMJK.js +30 -0
- package/dist/xfl-H3BXQPZZ.js +16 -0
- package/dist/xfl-XON7A7FI.js +69 -0
- package/package.json +366 -3
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { ReactElement, ImgHTMLAttributes } from 'react';
|
|
2
|
+
import { L as LogoUrlOptions, C as ColorOptions } from './marks-DH-tQIP-.js';
|
|
3
|
+
import { E as EspnHeadshotLeague } from './headshots-B2J_LOO8.js';
|
|
4
|
+
import { V as Value, R as ResolveOptions } from './resolve-CQW-jzvr.js';
|
|
5
|
+
import { S as SelectionStore, a as SelectionState } from './selection-D4T3PkRt.js';
|
|
6
|
+
import { L as League, S as SeasonInput, I as IdSystem, V as Variant, M as MarkType, W as Which, H as HeadshotIdSystem, T as TeamId } from './types-C7n6gJF3.js';
|
|
7
|
+
import { NivoLayerOptions } from './nivo.js';
|
|
8
|
+
import './_web-D7Aa5Rd8.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `<SurfaceBackdrop>` props: the league whose surface to draw, how to paint it (the options of sdvplot's other
|
|
12
|
+
* `surface` functions), and which axes place it. The sporty-specific options are typed loosely, so `sdvplot/react`'s
|
|
13
|
+
* types never name `@sportsdataverse/sporty` (an optional peer); sporty checks them when the surface is built.
|
|
14
|
+
*/
|
|
15
|
+
interface SurfaceBackdropProps {
|
|
16
|
+
/** The league whose court, field or rink to draw, e.g. "nba". */
|
|
17
|
+
league: League;
|
|
18
|
+
/** The team whose colours paint the surface. */
|
|
19
|
+
team?: Value;
|
|
20
|
+
/** The season the team's colours are taken from. */
|
|
21
|
+
season?: SeasonInput;
|
|
22
|
+
/** Overrides on top of the team painting, keyed by sporty colour key (e.g. `{ painted_area: "#0e2240" }`). */
|
|
23
|
+
colorUpdates?: Readonly<Record<string, string>>;
|
|
24
|
+
/** Degrees to rotate the surface by. */
|
|
25
|
+
rotation?: number;
|
|
26
|
+
/** A sporty display range for the league's sport, e.g. "defense"; one the sport does not know throws. */
|
|
27
|
+
displayRange?: string;
|
|
28
|
+
xlim?: readonly [number, number];
|
|
29
|
+
ylim?: readonly [number, number];
|
|
30
|
+
units?: "ft" | "m" | "yd" | "in" | "cm" | "mm";
|
|
31
|
+
/** Sporty parameter overrides for the league's surface. */
|
|
32
|
+
updates?: Readonly<Record<string, unknown>>;
|
|
33
|
+
arcResolution?: number;
|
|
34
|
+
xTrans?: number;
|
|
35
|
+
yTrans?: number;
|
|
36
|
+
/** The `xAxisId` of the numeric x axis the surface's units are on. Default 0. */
|
|
37
|
+
xAxisId?: string | number;
|
|
38
|
+
/** The `yAxisId` of the numeric y axis the surface's units are on. Default 0. */
|
|
39
|
+
yAxisId?: string | number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A team-painted court, field or rink under a Recharts chart's series: place it as a child of the chart (before the
|
|
43
|
+
* series), as Recharts 3 renders any element there (`<Customized>` is deprecated). The surface is drawn in the
|
|
44
|
+
* numeric axes' units: set both axes' `domain` to the surface's bbox (sporty's `surface(...).bbox`) to fill the plot
|
|
45
|
+
* area, or to any range in those units to show part of it. recharts (3.8 or later) and `@sportsdataverse/sporty`
|
|
46
|
+
* load when it first renders, never with `sdvplot/react`; either missing throws `OptionalDependencyError` then. A
|
|
47
|
+
* server render draws nothing (it loads on the client).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* import { SurfaceBackdrop } from "@sportsdataverse/sdvplot/react";
|
|
52
|
+
* import { surface } from "@sportsdataverse/sporty";
|
|
53
|
+
* import { Scatter, ScatterChart, XAxis, YAxis } from "recharts";
|
|
54
|
+
*
|
|
55
|
+
* const [x0, y0, x1, y1] = surface("basketball", "nba", { displayRange: "defense" }).bbox;
|
|
56
|
+
* <ScatterChart width={500} height={470}>
|
|
57
|
+
* <XAxis type="number" dataKey="x" domain={[x0, x1]} hide />
|
|
58
|
+
* <YAxis type="number" dataKey="y" domain={[y0, y1]} hide />
|
|
59
|
+
* <SurfaceBackdrop league="nba" team="DEN" displayRange="defense" />
|
|
60
|
+
* <Scatter data={[{ x: 0, y: 5.25 }]} />
|
|
61
|
+
* </ScatterChart>;
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function SurfaceBackdrop(props: SurfaceBackdropProps): ReactElement;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* `<LogoBump>` props: the series, the league their ids belong to, and how to draw the logos; every other prop goes to
|
|
68
|
+
* nivo's `Bump` as is (typed loosely, so `sdvplot/react`'s types never name `@nivo/bump`, an optional peer).
|
|
69
|
+
*/
|
|
70
|
+
interface LogoBumpProps {
|
|
71
|
+
/** nivo Bump series, `{ id, data: [{ x, y }] }`: each `id` is a team (abbreviation, name or id). */
|
|
72
|
+
data: readonly {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly data: readonly {
|
|
75
|
+
x: number | string;
|
|
76
|
+
y: number | null;
|
|
77
|
+
}[];
|
|
78
|
+
}[];
|
|
79
|
+
/** The league the series' teams belong to, e.g. "nfl". */
|
|
80
|
+
league: League;
|
|
81
|
+
/** The season the teams are resolved for. */
|
|
82
|
+
season?: SeasonInput;
|
|
83
|
+
/** How the series' ids are read. Default "auto". */
|
|
84
|
+
idSystem?: IdSystem;
|
|
85
|
+
/** The chart's background: the line colours keep 3:1 contrast against it and aim to stay distinct (`teamColors`). */
|
|
86
|
+
background?: string;
|
|
87
|
+
/** Logo height as a fraction of the plot height, in (0, 1]. Default 0.08. */
|
|
88
|
+
logoHeight?: number;
|
|
89
|
+
/** Which points get a logo: "last" (default), "first" or "all". */
|
|
90
|
+
at?: NivoLayerOptions["at"];
|
|
91
|
+
/** Logo variant, e.g. "dark". Default "default". */
|
|
92
|
+
variant?: Variant;
|
|
93
|
+
/** "logo" (default) or "wordmark". */
|
|
94
|
+
markType?: MarkType;
|
|
95
|
+
/** Width and height in px. Both given: a fixed-size `Bump`; otherwise a `ResponsiveBump` that fills its parent. */
|
|
96
|
+
width?: number;
|
|
97
|
+
/** Chart height in px (see `width`). */
|
|
98
|
+
height?: number;
|
|
99
|
+
/**
|
|
100
|
+
* nivo's layers. Default nivo's own: grid, axes, labels, lines, points, then the logos, then mesh. Given, the logos
|
|
101
|
+
* are appended after them all, after any "mesh" too, which is harmless: the logo layer has `pointer-events: none`.
|
|
102
|
+
*/
|
|
103
|
+
layers?: readonly unknown[];
|
|
104
|
+
/** Any other nivo `Bump` prop (margin, axes, pointSize, animate, theme, ...). */
|
|
105
|
+
[prop: string]: unknown;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A nivo bump chart of teams: each line in its team's colour (`teamColors`), a logo at the end of each line
|
|
109
|
+
* (`logoLayer`). `@nivo/bump` (0.99 or later) loads when it first renders, never with `sdvplot/react`; missing, it
|
|
110
|
+
* throws `OptionalDependencyError` then. A server render draws nothing (it loads on the client). For anything this
|
|
111
|
+
* does not cover, use `teamColors` and `logoLayer` from `sdvplot/nivo` on nivo's own `Bump`. A `colors` prop replaces
|
|
112
|
+
* the team colours (it is passed to nivo after them).
|
|
113
|
+
*/
|
|
114
|
+
declare function LogoBump({ league, season, idSystem, background, logoHeight, at, variant, markType, layers, ...rest }: LogoBumpProps): ReactElement;
|
|
115
|
+
|
|
116
|
+
interface Shared {
|
|
117
|
+
/** The league the teams belong to, e.g. "nfl". */
|
|
118
|
+
league: League;
|
|
119
|
+
/** Logo variant, e.g. "dark". Default "default". */
|
|
120
|
+
variant?: Variant;
|
|
121
|
+
/** How the team values are read. Default "auto". */
|
|
122
|
+
idSystem?: IdSystem;
|
|
123
|
+
/** "logo" (default) or "wordmark". */
|
|
124
|
+
markType?: MarkType;
|
|
125
|
+
/** url → data URI map from `embedSources`, to inline the images. */
|
|
126
|
+
embed?: ReadonlyMap<string, string>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* `<LogoPoint>` props: yours (the league, the datum field holding the team, ...), plus the point Victory hands its
|
|
130
|
+
* `dataComponent` (`x`, `y`, `size`, `datum`, `events`), which you leave out.
|
|
131
|
+
*/
|
|
132
|
+
interface LogoPointProps extends Shared {
|
|
133
|
+
/** The field of each datum (each data row) holding the team: abbreviation, name or id (see `idSystem`). */
|
|
134
|
+
team: string;
|
|
135
|
+
/** A season (number or string) for every point, or the name of the datum field holding each one's season. */
|
|
136
|
+
season?: SeasonInput;
|
|
137
|
+
/** Opacity in [0, 1]. Default 1. */
|
|
138
|
+
alpha?: number;
|
|
139
|
+
/** Set by Victory: the point's centre in px. */
|
|
140
|
+
x?: number;
|
|
141
|
+
/** Set by Victory: the point's centre in px. */
|
|
142
|
+
y?: number;
|
|
143
|
+
/** Set by Victory: the point's radius in px (the scatter's `size`). The logo is twice it tall. */
|
|
144
|
+
size?: number;
|
|
145
|
+
/** Set by Victory: the data row the point was drawn from. */
|
|
146
|
+
datum?: object;
|
|
147
|
+
/** Set by Victory: the point's event handlers (tooltips, voronoi, your `events`). */
|
|
148
|
+
events?: object;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* `<LogoTick>` props: yours (the league, the logo size, ...), plus the tick label Victory hands its
|
|
152
|
+
* `tickLabelComponent` (`x`, `y`, `text`, the anchors, and VictoryLabel's other props), which you leave out.
|
|
153
|
+
*/
|
|
154
|
+
interface LogoTickProps extends Shared {
|
|
155
|
+
/** The season the axis' teams are resolved for. */
|
|
156
|
+
season?: SeasonInput;
|
|
157
|
+
/** The logo's height in px, 1 or more (Victory hands a tick label no plot height). Default 24. */
|
|
158
|
+
size?: number;
|
|
159
|
+
/** Set by Victory: the label's anchor in px. */
|
|
160
|
+
x?: number;
|
|
161
|
+
/** Set by Victory: the label's anchor in px. */
|
|
162
|
+
y?: number;
|
|
163
|
+
/** Set by Victory: the tick's label, the team (abbreviation, name or id; see `idSystem`). */
|
|
164
|
+
text?: unknown;
|
|
165
|
+
/** Set by Victory: which side of the anchor the label would run. VictoryLabel's default "start". */
|
|
166
|
+
textAnchor?: string;
|
|
167
|
+
/** Set by Victory: which side of the anchor the label would hang. VictoryLabel's default "middle". */
|
|
168
|
+
verticalAnchor?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Team logos as a Victory scatter's points: `<VictoryScatter dataComponent={<LogoPoint league team />}>`. Each point
|
|
172
|
+
* draws the logo of its datum's `team` field, centred on the point and as tall as the point it replaces (twice the
|
|
173
|
+
* scatter's `size`, in px: set `size` on the `VictoryScatter`). A team with no logo draws nothing and warns once, as
|
|
174
|
+
* `sdvplot/echarts` does. Victory's event handlers (tooltips, voronoi) stay on the image. Synchronous: call it after
|
|
175
|
+
* `loadLeague(league)`. Needs nothing from victory itself, so it also renders on the server.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* import { loadLeague } from "@sportsdataverse/sdvplot";
|
|
180
|
+
* import { LogoPoint } from "@sportsdataverse/sdvplot/react";
|
|
181
|
+
* import { VictoryChart, VictoryScatter } from "victory";
|
|
182
|
+
*
|
|
183
|
+
* await loadLeague("nfl");
|
|
184
|
+
* const rows = [
|
|
185
|
+
* { team: "KC", pf: 385, pa: 326 },
|
|
186
|
+
* { team: "LAC", pf: 402, pa: 301 },
|
|
187
|
+
* { team: "DEN", pf: 425, pa: 311 },
|
|
188
|
+
* ];
|
|
189
|
+
* <VictoryChart domainPadding={30}>
|
|
190
|
+
* <VictoryScatter data={rows} x="pf" y="pa" size={14} dataComponent={<LogoPoint league="nfl" team="team" />} />
|
|
191
|
+
* </VictoryChart>;
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
declare function LogoPoint(props: LogoPointProps): ReactElement | null;
|
|
195
|
+
/**
|
|
196
|
+
* Team logos as an axis' tick labels: `<VictoryAxis tickLabelComponent={<LogoTick league />} />` on an axis whose
|
|
197
|
+
* labels are teams. The logo sits where the label would, on the side of Victory's anchor the label would run (under
|
|
198
|
+
* a bottom axis, left of a left one), `size` px tall. A label that resolves to no logo keeps its text, drawn by
|
|
199
|
+
* Victory's own `VictoryLabel` (loaded from victory when it first draws one; it then also warns once), as
|
|
200
|
+
* `sdvplot/echarts`' `withAxisLogos` does. Logos do not
|
|
201
|
+
* rotate with a tick's `angle`. Synchronous: call it after `loadLeague(league)`.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```tsx
|
|
205
|
+
* import { loadLeague } from "@sportsdataverse/sdvplot";
|
|
206
|
+
* import { LogoTick } from "@sportsdataverse/sdvplot/react";
|
|
207
|
+
* import { VictoryAxis, VictoryBar, VictoryChart } from "victory";
|
|
208
|
+
*
|
|
209
|
+
* await loadLeague("nfl");
|
|
210
|
+
* const rows = [
|
|
211
|
+
* { team: "KC", wins: 15 },
|
|
212
|
+
* { team: "BUF", wins: 13 },
|
|
213
|
+
* { team: "LAC", wins: 11 },
|
|
214
|
+
* ];
|
|
215
|
+
* <VictoryChart domainPadding={40} padding={{ top: 20, bottom: 60, left: 50, right: 20 }}>
|
|
216
|
+
* <VictoryAxis tickLabelComponent={<LogoTick league="nfl" size={32} />} />
|
|
217
|
+
* <VictoryAxis dependentAxis />
|
|
218
|
+
* <VictoryBar data={rows} x="team" y="wins" />
|
|
219
|
+
* </VictoryChart>;
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare function LogoTick(props: LogoTickProps): ReactElement;
|
|
223
|
+
|
|
224
|
+
/** `<Surface3D>` props: sporty's sport and league, and sporty's `surface()` options. */
|
|
225
|
+
interface Surface3DProps {
|
|
226
|
+
/** sporty's sport, e.g. "baseball". */
|
|
227
|
+
sport: string;
|
|
228
|
+
/** sporty's league key for it, e.g. "mlb". */
|
|
229
|
+
league: string;
|
|
230
|
+
/** sporty's `surface()` options (`colorUpdates`, `units`, `rotation`, ...). */
|
|
231
|
+
options?: Record<string, unknown>;
|
|
232
|
+
/** The mesh's `renderOrder`. Default -1: drawn before the scene's other objects, as a ground should be. */
|
|
233
|
+
renderOrder?: number;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* sporty's playing surface in a react-three-fiber scene: `surfaceMesh` as one mesh in the z = 0 plane, in the
|
|
237
|
+
* surface's own units (feet for a baseball field or a rink, metres for a pitch), z up, so set the camera's
|
|
238
|
+
* `up={[0, 0, 1]}`. Drawn unlit in sporty's colours, before the scene's other objects and without depth writes, so its
|
|
239
|
+
* features paint over each other in order with no z-fighting. Put it inside your `<Canvas>`. `three` and
|
|
240
|
+
* `@react-three/fiber` (0.186.1 and 9.8.1 or later) and `@sportsdataverse/sporty` load when it first renders, never
|
|
241
|
+
* with `sdvplot/react`; a missing peer throws `OptionalDependencyError` then. The failed load is kept until the page
|
|
242
|
+
* reloads, so installing the peer needs a reload. A server render draws nothing.
|
|
243
|
+
*
|
|
244
|
+
* See it drawn in the Three.js guide (`sdvplot/three/statcast-pitches` in the gallery).
|
|
245
|
+
*/
|
|
246
|
+
declare function Surface3D(props: Surface3DProps): ReactElement;
|
|
247
|
+
/** `<Trajectory>` props: the path, the tube's radius in world units, and its colour or team. */
|
|
248
|
+
interface TrajectoryProps {
|
|
249
|
+
/** The path, `[x, y, z]` points in world units (`statcastPitchPath` gives a pitch's). */
|
|
250
|
+
points: readonly (readonly [x: number, y: number, z: number])[];
|
|
251
|
+
/** The tube's radius in the points' world units, not px (a baseball's is 0.121 ft). */
|
|
252
|
+
radius: number;
|
|
253
|
+
/** Vertices round each ring, 3 or more. Default 12. */
|
|
254
|
+
radialSegments?: number;
|
|
255
|
+
/** The tube's colour, `#rrggbb`. Give this or `team` and `league`. */
|
|
256
|
+
color?: string;
|
|
257
|
+
/** The team whose colour the tube takes (abbreviation, name or id), with `league`. */
|
|
258
|
+
team?: unknown;
|
|
259
|
+
league?: League;
|
|
260
|
+
season?: SeasonInput;
|
|
261
|
+
idSystem?: IdSystem;
|
|
262
|
+
/** "primary" (default) or "secondary". */
|
|
263
|
+
which?: Which;
|
|
264
|
+
/** What the tube is seen against: the colour keeps 3:1 contrast against it (`teamColorPalette`). */
|
|
265
|
+
background?: string;
|
|
266
|
+
/** The colour of a team that does not resolve. Default "#808080". */
|
|
267
|
+
fallback?: string;
|
|
268
|
+
/** The mesh's `renderOrder`. Default 0. */
|
|
269
|
+
renderOrder?: number;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* A team-coloured tube along a 3D path (a pitch, a ball flight) in a react-three-fiber scene: `trajectoryTube` as one
|
|
273
|
+
* mesh, `radius` round in the points' world units, drawn unlit and not tone-mapped so the team's colour shows as it
|
|
274
|
+
* is. Put it inside your `<Canvas>`, over a `<Surface3D>` in the same units. `three` and `@react-three/fiber` load
|
|
275
|
+
* when it first renders, never with `sdvplot/react`; a missing peer throws `OptionalDependencyError` then (kept until
|
|
276
|
+
* the page reloads, so installing the peer needs a reload), and a bad radius or colour throws `InputError`. With
|
|
277
|
+
* `team`, the team's league must be loaded for its colour: until it is, the tube draws nothing (one warning), and in
|
|
278
|
+
* the browser it loads the league and then draws. A server render draws nothing.
|
|
279
|
+
*
|
|
280
|
+
* See it drawn in the Three.js guide (`sdvplot/three/statcast-pitches` in the gallery).
|
|
281
|
+
*/
|
|
282
|
+
declare function Trajectory({ points, renderOrder, ...o }: TrajectoryProps): ReactElement | null;
|
|
283
|
+
|
|
284
|
+
type ImgProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt" | "height" | "width">;
|
|
285
|
+
interface TeamLogoProps extends ImgProps {
|
|
286
|
+
team: Value;
|
|
287
|
+
league: League;
|
|
288
|
+
season?: LogoUrlOptions["season"];
|
|
289
|
+
variant?: Variant;
|
|
290
|
+
markType?: MarkType;
|
|
291
|
+
/** Rendered `height` in px; width is left unset so the browser keeps the aspect. */
|
|
292
|
+
size?: number;
|
|
293
|
+
/** Defaults to the team's name. */
|
|
294
|
+
alt?: string;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Team logo `<img>`. Loads the league index on first use; renders nothing until resolved and for an unknown team.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```tsx
|
|
301
|
+
* import { TeamLogo } from "@sportsdataverse/sdvplot/react";
|
|
302
|
+
*
|
|
303
|
+
* <TeamLogo team="KC" league="nfl" size={64} />;
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
declare function TeamLogo({ team, league, season, variant, markType, size, alt, ...imgProps }: TeamLogoProps): ReactElement | null;
|
|
307
|
+
/** `TeamLogo` with `markType="wordmark"`. */
|
|
308
|
+
declare function Wordmark(props: Omit<TeamLogoProps, "markType">): ReactElement | null;
|
|
309
|
+
interface HeadshotProps extends ImgProps {
|
|
310
|
+
playerId: Value;
|
|
311
|
+
league: EspnHeadshotLeague;
|
|
312
|
+
idSystem?: HeadshotIdSystem;
|
|
313
|
+
/** Height in px (default 60); width follows the 600:436 headshot aspect. */
|
|
314
|
+
height?: number;
|
|
315
|
+
/** Default `name`, then "Player headshot". `""` marks it decorative (the initials box is then `aria-hidden`). */
|
|
316
|
+
alt?: string;
|
|
317
|
+
/**
|
|
318
|
+
* `"initials"`: when there is no headshot URL or the image fails to load, show up to three initials of `name` in a
|
|
319
|
+
* box of the headshot's size (blazing-the-nets `main` `components/Headshot.tsx:15-29`). Default `"none"`: a failed
|
|
320
|
+
* load leaves the `<img>`, and an id with no URL renders nothing.
|
|
321
|
+
*/
|
|
322
|
+
fallback?: "none" | "initials";
|
|
323
|
+
/** The player's name, for the initials and the default alt text. */
|
|
324
|
+
name?: string;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Player headshot `<img>`: sync for ESPN ids; gsis ids render once the gsis map has loaded. Renders nothing for an
|
|
328
|
+
* unknown/malformed id, or a league/idSystem `headshotUrl` rejects, unless `fallback="initials"` and a `name` are
|
|
329
|
+
* given, which show the player's initials instead.
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```tsx
|
|
333
|
+
* import { Headshot } from "@sportsdataverse/sdvplot/react";
|
|
334
|
+
*
|
|
335
|
+
* <Headshot playerId="3918298" league="nfl" height={80} alt="Josh Allen" />;
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
declare function Headshot({ playerId, league, idSystem, height, alt, fallback, name, ...imgProps }: HeadshotProps): ReactElement | null;
|
|
339
|
+
/** `{team: "#hex"}` for a league once loaded (`undefined` before); reloads when `league`/`which` change. */
|
|
340
|
+
declare function useTeamColors(league: League, { which }?: {
|
|
341
|
+
which?: ColorOptions["which"];
|
|
342
|
+
}): Record<string, string> | undefined;
|
|
343
|
+
/** Sync resolver `(value, opts?) => TeamId | undefined` once the league is loaded (`undefined` before); reloads when `league` changes. */
|
|
344
|
+
declare function useResolve(league: League): ((value: Value, opts?: ResolveOptions) => TeamId | undefined) | undefined;
|
|
345
|
+
/**
|
|
346
|
+
* The state of a `createSelection` store (J31), re-rendering on every change and never on a no-op patch. On the
|
|
347
|
+
* server, and in the first client render, it reads the store's current state, so server and client markup agree.
|
|
348
|
+
* Redrawing from it is the component's choice: filter rows with `state.predicate`, emphasise `state.selected`.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```tsx
|
|
352
|
+
* import { createSelection } from "@sportsdataverse/sdvplot";
|
|
353
|
+
* import { useSelection } from "@sportsdataverse/sdvplot/react";
|
|
354
|
+
* import type { ReactElement } from "react";
|
|
355
|
+
*
|
|
356
|
+
* const store = createSelection();
|
|
357
|
+
* store.set({ selected: ["KC", "BUF"] });
|
|
358
|
+
* function Picked(): ReactElement {
|
|
359
|
+
* const { selected } = useSelection(store); // re-renders on every change of the store
|
|
360
|
+
* return (
|
|
361
|
+
* <table>
|
|
362
|
+
* <tbody>
|
|
363
|
+
* {[...selected].map((id) => (
|
|
364
|
+
* <tr key={id}>
|
|
365
|
+
* <td>{id}</td>
|
|
366
|
+
* </tr>
|
|
367
|
+
* ))}
|
|
368
|
+
* </tbody>
|
|
369
|
+
* </table>
|
|
370
|
+
* );
|
|
371
|
+
* }
|
|
372
|
+
* <Picked />;
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
declare function useSelection<Row>(store: SelectionStore<Row>): SelectionState<Row>;
|
|
376
|
+
|
|
377
|
+
export { Headshot, type HeadshotProps, LogoBump, type LogoBumpProps, LogoPoint, type LogoPointProps, LogoTick, type LogoTickProps, Surface3D, type Surface3DProps, SurfaceBackdrop, type SurfaceBackdropProps, TeamLogo, type TeamLogoProps, Trajectory, type TrajectoryProps, Wordmark, useResolve, useSelection, useTeamColors };
|