@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.
Files changed (245) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +109 -0
  3. package/README.md +984 -2
  4. package/dist/_web-D7Aa5Rd8.d.ts +69 -0
  5. package/dist/aaf-GJ3SH34T.js +13 -0
  6. package/dist/aaf-HCYN5T6Y.js +37 -0
  7. package/dist/aaf-ZAE5KS2Y.js +13 -0
  8. package/dist/ahl-E66MDVCU.js +66 -0
  9. package/dist/ahl-NPQQWZEV.js +249 -0
  10. package/dist/ahl-QRDU73XX.js +309 -0
  11. package/dist/axis-CraWQRUJ.d.ts +49 -0
  12. package/dist/bins.d.ts +174 -0
  13. package/dist/bins.js +4 -0
  14. package/dist/bins.js.map +1 -0
  15. package/dist/cfb-F42SVS4X.js +5000 -0
  16. package/dist/cfb-P3SHEYRZ.js +692 -0
  17. package/dist/cfb-WXRZANLP.js +10226 -0
  18. package/dist/chartjs-surface.d.ts +42 -0
  19. package/dist/chartjs-surface.js +65 -0
  20. package/dist/chartjs-surface.js.map +1 -0
  21. package/dist/chartjs.d.ts +162 -0
  22. package/dist/chartjs.js +342 -0
  23. package/dist/chartjs.js.map +1 -0
  24. package/dist/chunk-4C3GX6QO.js +92 -0
  25. package/dist/chunk-4C3GX6QO.js.map +1 -0
  26. package/dist/chunk-57WFSI4Q.js +128 -0
  27. package/dist/chunk-57WFSI4Q.js.map +1 -0
  28. package/dist/chunk-7ULOCCFL.js +313 -0
  29. package/dist/chunk-7ULOCCFL.js.map +1 -0
  30. package/dist/chunk-AMXASQHT.js +120 -0
  31. package/dist/chunk-AMXASQHT.js.map +1 -0
  32. package/dist/chunk-B2MP37SR.js +175 -0
  33. package/dist/chunk-B2MP37SR.js.map +1 -0
  34. package/dist/chunk-C2CDY5OG.js +137 -0
  35. package/dist/chunk-C2CDY5OG.js.map +1 -0
  36. package/dist/chunk-DYMUVE6K.js +127 -0
  37. package/dist/chunk-DYMUVE6K.js.map +1 -0
  38. package/dist/chunk-E7G7VSLV.js +43 -0
  39. package/dist/chunk-E7G7VSLV.js.map +1 -0
  40. package/dist/chunk-H2C3FMMA.js +300 -0
  41. package/dist/chunk-H2C3FMMA.js.map +1 -0
  42. package/dist/chunk-J4P4HDBF.js +175 -0
  43. package/dist/chunk-J4P4HDBF.js.map +1 -0
  44. package/dist/chunk-J6R2LEJ7.js +58 -0
  45. package/dist/chunk-J6R2LEJ7.js.map +1 -0
  46. package/dist/chunk-M3XD2OSN.js +132 -0
  47. package/dist/chunk-M3XD2OSN.js.map +1 -0
  48. package/dist/chunk-OIILARXI.js +30 -0
  49. package/dist/chunk-OIILARXI.js.map +1 -0
  50. package/dist/chunk-RPVVJY74.js +170 -0
  51. package/dist/chunk-RPVVJY74.js.map +1 -0
  52. package/dist/chunk-UL5M6KDE.js +205 -0
  53. package/dist/chunk-UL5M6KDE.js.map +1 -0
  54. package/dist/chunk-WQT4IVLX.js +10 -0
  55. package/dist/chunk-WQT4IVLX.js.map +1 -0
  56. package/dist/chunk-ZAEQXFJM.js +556 -0
  57. package/dist/chunk-ZAEQXFJM.js.map +1 -0
  58. package/dist/cricket-KPCYG2HL.js +493 -0
  59. package/dist/cricket-NDXLE25B.js +116 -0
  60. package/dist/cricket-YUUF7P6M.js +160 -0
  61. package/dist/cytoscape.d.ts +188 -0
  62. package/dist/cytoscape.js +219 -0
  63. package/dist/cytoscape.js.map +1 -0
  64. package/dist/d3.d.ts +234 -0
  65. package/dist/d3.js +198 -0
  66. package/dist/d3.js.map +1 -0
  67. package/dist/deckgl.d.ts +232 -0
  68. package/dist/deckgl.js +197 -0
  69. package/dist/deckgl.js.map +1 -0
  70. package/dist/echarts.d.ts +121 -0
  71. package/dist/echarts.js +228 -0
  72. package/dist/echarts.js.map +1 -0
  73. package/dist/echl-3CR4RGFC.js +241 -0
  74. package/dist/echl-NPC32C23.js +107 -0
  75. package/dist/echl-PI33DGJC.js +64 -0
  76. package/dist/export.d.ts +130 -0
  77. package/dist/export.js +258 -0
  78. package/dist/export.js.map +1 -0
  79. package/dist/g2.d.ts +251 -0
  80. package/dist/g2.js +102 -0
  81. package/dist/g2.js.map +1 -0
  82. package/dist/headshots-B2J_LOO8.d.ts +40 -0
  83. package/dist/index.d.ts +183 -0
  84. package/dist/index.js +9 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/interact.d.ts +567 -0
  87. package/dist/interact.js +809 -0
  88. package/dist/interact.js.map +1 -0
  89. package/dist/lightweight-charts.d.ts +217 -0
  90. package/dist/lightweight-charts.js +155 -0
  91. package/dist/lightweight-charts.js.map +1 -0
  92. package/dist/maplibre.d.ts +271 -0
  93. package/dist/maplibre.js +175 -0
  94. package/dist/maplibre.js.map +1 -0
  95. package/dist/marks-DH-tQIP-.d.ts +75 -0
  96. package/dist/mbb-3TRLVW3H.js +3619 -0
  97. package/dist/mbb-DQUHCHZP.js +5111 -0
  98. package/dist/mbb-PRAIO2P5.js +371 -0
  99. package/dist/milb-6IQ6NCEW.js +291 -0
  100. package/dist/milb-EYY5MD4T.js +1752 -0
  101. package/dist/milb-EYZ4SZLI.js +797 -0
  102. package/dist/mlb-4PBUJSVQ.js +35 -0
  103. package/dist/mlb-FHPY3GQJ.js +701 -0
  104. package/dist/mlb-REVGL3N2.js +665 -0
  105. package/dist/mui.d.ts +338 -0
  106. package/dist/mui.js +184 -0
  107. package/dist/mui.js.map +1 -0
  108. package/dist/nba-ATT775GS.js +485 -0
  109. package/dist/nba-LKM4UHVU.js +482 -0
  110. package/dist/nba-YX7PXM3R.js +35 -0
  111. package/dist/nbagl-3WGZCZ4S.js +37 -0
  112. package/dist/nbagl-LP4XJRAL.js +229 -0
  113. package/dist/nbagl-VTTOU7LN.js +499 -0
  114. package/dist/ncaa_baseball-UV75LNVR.js +2670 -0
  115. package/dist/ncaa_baseball-VD5J5C72.js +419 -0
  116. package/dist/ncaa_baseball-YRBS32D6.js +4592 -0
  117. package/dist/ncaa_mhockey-IMYHS7QS.js +1033 -0
  118. package/dist/ncaa_mhockey-TXTKWHE3.js +115 -0
  119. package/dist/ncaa_mhockey-U3MFW5VT.js +663 -0
  120. package/dist/ncaa_softball-6WR6KS64.js +420 -0
  121. package/dist/ncaa_softball-RZCTIE56.js +2654 -0
  122. package/dist/ncaa_softball-VOD4PVGY.js +4599 -0
  123. package/dist/ncaa_whockey-6XXGUTBK.js +607 -0
  124. package/dist/ncaa_whockey-AKKYKY67.js +53 -0
  125. package/dist/ncaa_whockey-KBEKXFBB.js +293 -0
  126. package/dist/nfl-BDB2HYAR.js +625 -0
  127. package/dist/nfl-EHYHDLJD.js +37 -0
  128. package/dist/nfl-VF4NJCHY.js +514 -0
  129. package/dist/nfl_gsis-UY64JO37.js +4 -0
  130. package/dist/nhl-6WPHME7H.js +511 -0
  131. package/dist/nhl-EMIJFZHY.js +884 -0
  132. package/dist/nhl-ISFUKRFU.js +37 -0
  133. package/dist/nivo.d.ts +193 -0
  134. package/dist/nivo.js +8 -0
  135. package/dist/nivo.js.map +1 -0
  136. package/dist/ohl-2FEM554G.js +113 -0
  137. package/dist/ohl-C5Q4W6JB.js +32 -0
  138. package/dist/ohl-TQ4J46VC.js +66 -0
  139. package/dist/perspective.d.ts +198 -0
  140. package/dist/perspective.js +171 -0
  141. package/dist/perspective.js.map +1 -0
  142. package/dist/phf-H7POU2KW.js +32 -0
  143. package/dist/phf-K5IFMZUM.js +13 -0
  144. package/dist/phf-TWJI3BOW.js +20 -0
  145. package/dist/placement-UWkqUzpa.d.ts +32 -0
  146. package/dist/plot.d.ts +451 -0
  147. package/dist/plot.js +712 -0
  148. package/dist/plot.js.map +1 -0
  149. package/dist/plotly.d.ts +129 -0
  150. package/dist/plotly.js +360 -0
  151. package/dist/plotly.js.map +1 -0
  152. package/dist/pwhl-OX3BO4JI.js +53 -0
  153. package/dist/pwhl-W44OC3C6.js +17 -0
  154. package/dist/pwhl-ZJGG3H7W.js +23 -0
  155. package/dist/qmjhl-5HISEHLL.js +35 -0
  156. package/dist/qmjhl-DA3UHKE5.js +125 -0
  157. package/dist/qmjhl-YG4BOQPF.js +614 -0
  158. package/dist/react.d.ts +377 -0
  159. package/dist/react.js +522 -0
  160. package/dist/react.js.map +1 -0
  161. package/dist/recharts.d.ts +162 -0
  162. package/dist/recharts.js +8 -0
  163. package/dist/recharts.js.map +1 -0
  164. package/dist/resolve-CQW-jzvr.d.ts +28 -0
  165. package/dist/selection-D4T3PkRt.d.ts +140 -0
  166. package/dist/shadcn.d.ts +83 -0
  167. package/dist/shadcn.js +88 -0
  168. package/dist/shadcn.js.map +1 -0
  169. package/dist/shots.d.ts +364 -0
  170. package/dist/shots.js +86 -0
  171. package/dist/shots.js.map +1 -0
  172. package/dist/soccer-7BH3ZLVL.js +7898 -0
  173. package/dist/soccer-MRU25OGE.js +2636 -0
  174. package/dist/soccer-PF4IPPVA.js +12342 -0
  175. package/dist/surface-TR7YFJW3.js +4 -0
  176. package/dist/surface-TR7YFJW3.js.map +1 -0
  177. package/dist/surfaces-MIG7HOFU.js +6 -0
  178. package/dist/surfaces-MIG7HOFU.js.map +1 -0
  179. package/dist/surfaces-W-odWLpT.d.ts +47 -0
  180. package/dist/svelte/HeadshotMark.svelte +25 -0
  181. package/dist/svelte/HeadshotMark.svelte.d.ts +10 -0
  182. package/dist/svelte/HeadshotMark.svelte.d.ts.map +1 -0
  183. package/dist/svelte/LogoMark.svelte +25 -0
  184. package/dist/svelte/LogoMark.svelte.d.ts +10 -0
  185. package/dist/svelte/LogoMark.svelte.d.ts.map +1 -0
  186. package/dist/svelte/Marks.svelte +25 -0
  187. package/dist/svelte/Marks.svelte.d.ts +10 -0
  188. package/dist/svelte/Marks.svelte.d.ts.map +1 -0
  189. package/dist/svelte/Surface.svelte +29 -0
  190. package/dist/svelte/Surface.svelte.d.ts +9 -0
  191. package/dist/svelte/Surface.svelte.d.ts.map +1 -0
  192. package/dist/svelte/SurfaceBackdrop.svelte +26 -0
  193. package/dist/svelte/SurfaceBackdrop.svelte.d.ts +11 -0
  194. package/dist/svelte/SurfaceBackdrop.svelte.d.ts.map +1 -0
  195. package/dist/svelte/index.d.ts +13 -0
  196. package/dist/svelte/index.d.ts.map +1 -0
  197. package/dist/svelte/index.js +11 -0
  198. package/dist/svelte-core.d.ts +139 -0
  199. package/dist/svelte-core.js +123 -0
  200. package/dist/svelte-core.js.map +1 -0
  201. package/dist/tanstack.d.ts +240 -0
  202. package/dist/tanstack.js +110 -0
  203. package/dist/tanstack.js.map +1 -0
  204. package/dist/testing.d.ts +75 -0
  205. package/dist/testing.js +239 -0
  206. package/dist/testing.js.map +1 -0
  207. package/dist/three.d.ts +223 -0
  208. package/dist/three.js +50 -0
  209. package/dist/three.js.map +1 -0
  210. package/dist/tiers-BN4md-GB.d.ts +65 -0
  211. package/dist/types-C7n6gJF3.d.ts +62 -0
  212. package/dist/ufl-7VLZTLTT.js +143 -0
  213. package/dist/ufl-CCMBLPSW.js +100 -0
  214. package/dist/ufl-F2BJRXME.js +16 -0
  215. package/dist/unovis.d.ts +127 -0
  216. package/dist/unovis.js +108 -0
  217. package/dist/unovis.js.map +1 -0
  218. package/dist/uplot.d.ts +120 -0
  219. package/dist/uplot.js +110 -0
  220. package/dist/uplot.js.map +1 -0
  221. package/dist/usfl-4CR5RMZJ.js +32 -0
  222. package/dist/usfl-LD7HP2YK.js +14 -0
  223. package/dist/usfl-VU4YSJQD.js +19 -0
  224. package/dist/ushl-CPG2LB4L.js +73 -0
  225. package/dist/ushl-PQL6HJAD.js +88 -0
  226. package/dist/ushl-ZT2ATPHK.js +22 -0
  227. package/dist/vega.d.ts +85 -0
  228. package/dist/vega.js +362 -0
  229. package/dist/vega.js.map +1 -0
  230. package/dist/victory.d.ts +107 -0
  231. package/dist/victory.js +38 -0
  232. package/dist/victory.js.map +1 -0
  233. package/dist/wbb-3KHCDYTK.js +5087 -0
  234. package/dist/wbb-BMX53Q3Q.js +369 -0
  235. package/dist/wbb-QNRN2CJJ.js +3620 -0
  236. package/dist/whl-4ATYZWUB.js +97 -0
  237. package/dist/whl-RVFPL6MH.js +79 -0
  238. package/dist/whl-Y7ASKYMM.js +28 -0
  239. package/dist/wnba-FWX5SFVI.js +232 -0
  240. package/dist/wnba-GX6HZR4B.js +220 -0
  241. package/dist/wnba-NTMWIPP6.js +20 -0
  242. package/dist/xfl-43R2JMJK.js +30 -0
  243. package/dist/xfl-H3BXQPZZ.js +16 -0
  244. package/dist/xfl-XON7A7FI.js +69 -0
  245. package/package.json +366 -3
@@ -0,0 +1,49 @@
1
+ import * as Plot from '@observablehq/plot';
2
+ import { L as League, S as SeasonInput, V as Variant, M as MarkType, I as IdSystem } from './types-C7n6gJF3.js';
3
+
4
+ type Axis = "x" | "y" | "fx" | "fy";
5
+ /**
6
+ * Plot's axis options sdvplot does not own pass through: `ticks`, `tickSpacing`, `tickPadding`, `tickRotate`,
7
+ * `fontSize`, `fill`, `ariaLabel`, `ariaDescription`, `facetAnchor`, `className`, the margins, and the rest. A
8
+ * `render` you pass wraps sdvplot's (it sees the images). sdvplot owns `tickFormat` (the tick text becomes the
9
+ * image); `anchor`, `tickSize` and `label` are sdvplot's own options below.
10
+ */
11
+ type AxisPassThrough = Omit<Plot.AxisXOptions, "tickFormat" | "anchor" | "tickSize" | "label">;
12
+ /**
13
+ * Options for `axisLogos`. Each drawn image is named by the tick it replaces ("KC logo", "KC wordmark"), so assistive
14
+ * technology reads the category the text showed. The images are sized by `height` (a fraction of the frame); a caller
15
+ * margin on the anchored side smaller than the computed one can clip them.
16
+ */
17
+ interface AxisLogosOptions extends AxisPassThrough {
18
+ league: League;
19
+ season?: SeasonInput;
20
+ /** Fraction of the frame height in (0, 1]; default 0.1. */
21
+ height?: number;
22
+ variant?: Variant;
23
+ markType?: MarkType;
24
+ idSystem?: IdSystem;
25
+ anchor?: "top" | "bottom" | "left" | "right";
26
+ tickSize?: number;
27
+ label?: string | null;
28
+ }
29
+ /**
30
+ * Axis mark whose tick text is swapped for the team image; categories that do not resolve keep their text.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import * as Plot from "@observablehq/plot";
35
+ * import { loadLeague } from "@sportsdataverse/sdvplot";
36
+ * import { axisLogos } from "@sportsdataverse/sdvplot/plot";
37
+ *
38
+ * await loadLeague("nfl");
39
+ * const wins = [
40
+ * { team: "KC", wins: 15 },
41
+ * { team: "BUF", wins: 13 },
42
+ * { team: "LAC", wins: 11 },
43
+ * ];
44
+ * Plot.plot({ marks: [Plot.barY(wins, { x: "team", y: "wins" }), axisLogos("x", { league: "nfl" })] });
45
+ * ```
46
+ */
47
+ declare function axisLogos(axis: Axis, o: AxisLogosOptions): Plot.Markish;
48
+
49
+ export { type Axis as A, type AxisLogosOptions as a, type AxisPassThrough as b, axisLogos as c };
package/dist/bins.d.ts ADDED
@@ -0,0 +1,174 @@
1
+ /** One bin of either shape (`hexbin`, `squarebin`): the points in it, plus its centre in the points' own units. */
2
+ type BinOf<T> = T[] & {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ /**
7
+ * Bin points into pointy-top hexagons of circumradius `radius`, in the points' OWN units (data space, not
8
+ * pixels). Points with a NaN coordinate are skipped. Centres of `-0` are folded to `0` (blazing-the-nets
9
+ * `main` `lib/data/aggregate.ts:101`), so equal hexes share one key. Throws `InputError` unless `radius` is a finite
10
+ * number greater than 0.
11
+ *
12
+ * Each point goes to the centre upstream d3-hexbin picks, which is close to but not exactly the nearest one: it
13
+ * compares two candidates' squared distances in lattice units (x over √3·radius, y over 1.5·radius; `:43`), so
14
+ * about 1-2% of points sit just outside the hexagon drawn for their bin (on the real BKN fixture, 22 of 2000 shots
15
+ * at radius 10 and 37 of 2000 at radius 15). That is faithful to d3-hexbin and to blazing-the-nets, which draw the
16
+ * same; do not "fix" it. Squares (`squarebin`) contain every point they bin.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { hexbin } from "@sportsdataverse/sdvplot/bins";
21
+ *
22
+ * // three Brooklyn shots of 2025-26 in tenths of a foot from the hoop (sportsdataverse-data nba_stats_shots): the
23
+ * // two at the rim share a 1 ft hexagon, so this is 2
24
+ * const shots = [
25
+ * { x_legacy: 0, y_legacy: 0 },
26
+ * { x_legacy: -1, y_legacy: 7 },
27
+ * { x_legacy: -44, y_legacy: 252 },
28
+ * ];
29
+ * hexbin(shots, { radius: 10, x: (s) => s.x_legacy, y: (s) => s.y_legacy }).length;
30
+ * ```
31
+ */
32
+ declare function hexbin<T>(points: readonly T[], o: {
33
+ radius: number;
34
+ x: (p: T) => number;
35
+ y: (p: T) => number;
36
+ }): BinOf<T>[];
37
+ /**
38
+ * An SVG path for a hexagon of circumradius `r` centred on the current point, byte-identical to d3-hexbin's
39
+ * `hexbin.hexagon(r)`: `selection.attr("transform", translate(cx, cy)).attr("d", hexagonPath(r))`.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * import { hexagonPath } from "@sportsdataverse/sdvplot/bins";
44
+ *
45
+ * hexagonPath(10);
46
+ * ```
47
+ */
48
+ declare function hexagonPath(r: number): string;
49
+
50
+ /** The cell shape of a lattice. */
51
+ type BinShape = "hex" | "square";
52
+ /**
53
+ * A cell lattice as plain JSON: pointy-top hexagons of circumradius `radius` (d3-hexbin's), squares of side `side`,
54
+ * or (`equalArea: true`) the square with the same area as a hexagon of circumradius `radius`.
55
+ */
56
+ type BinnerOptions = {
57
+ readonly shape?: "hex";
58
+ readonly radius: number;
59
+ } | {
60
+ readonly shape: "square";
61
+ readonly side: number;
62
+ } | {
63
+ readonly shape: "square";
64
+ readonly radius: number;
65
+ readonly equalArea: true;
66
+ };
67
+ /** A lattice with `equalArea` resolved: what an index stores so a later binning reproduces the same cells. */
68
+ type Lattice = {
69
+ readonly shape?: "hex";
70
+ readonly radius: number;
71
+ } | {
72
+ readonly shape: "square";
73
+ readonly side: number;
74
+ };
75
+ /** One lattice, either shape. */
76
+ interface Binner {
77
+ /** `"hex"` or `"square"`. */
78
+ readonly shape: BinShape;
79
+ /** The full cell size in the points' units: the hexagon's circumradius, or the square's side. */
80
+ readonly size: number;
81
+ /** The resolved options: `{ radius }` for hexagons, `{ shape: "square", side }` for squares. */
82
+ readonly lattice: Lattice;
83
+ /** Bin points (`hexbin` or `squarebin`). */
84
+ bins<T>(points: readonly T[], o: {
85
+ x: (p: T) => number;
86
+ y: (p: T) => number;
87
+ }): BinOf<T>[];
88
+ /** An SVG path for one cell of size `s` (default `size`) centred on the current point. */
89
+ cell(s?: number): string;
90
+ }
91
+ /**
92
+ * Bin points into axis-aligned squares of side `side`, in the points' OWN units. As in d3-hexbin's lattice, a cell
93
+ * is centred on the origin, so centres are `(i·side, j·side)`. Cells are half-open, `[c − side/2, c + side/2)` on
94
+ * each axis: a point exactly on an edge goes to the higher cell, because the cell index is `Math.round(x / side)`,
95
+ * the rounding d3-hexbin uses (`hexbin.js:33-34`). Bins come out in first-seen order; points with a NaN coordinate
96
+ * are skipped; centres of `-0` fold to `0`. Throws `InputError` unless `side` is a finite number greater than 0.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { squarebin } from "@sportsdataverse/sdvplot/bins";
101
+ *
102
+ * // three Brooklyn shots of 2025-26 (sportsdataverse-data nba_stats_shots); x = 5 sits on a cell edge and goes to
103
+ * // the higher cell: [[0, 0, 1], [0, 10, 1], [10, 90, 1]]
104
+ * const shots = [
105
+ * { x_legacy: 0, y_legacy: 0 },
106
+ * { x_legacy: -1, y_legacy: 7 },
107
+ * { x_legacy: 5, y_legacy: 91 },
108
+ * ];
109
+ * squarebin(shots, { side: 10, x: (s) => s.x_legacy, y: (s) => s.y_legacy }).map((b) => [b.x, b.y, b.length]);
110
+ * ```
111
+ */
112
+ declare function squarebin<T>(points: readonly T[], o: {
113
+ side: number;
114
+ x: (p: T) => number;
115
+ y: (p: T) => number;
116
+ }): BinOf<T>[];
117
+ /**
118
+ * An SVG path for a square of side `s` centred on the current point, drawn the way `hexagonPath` is:
119
+ * `selection.attr("transform", translate(cx, cy)).attr("d", squarePath(s))`.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { squarePath } from "@sportsdataverse/sdvplot/bins";
124
+ *
125
+ * squarePath(10); // "m-5,-5h10v10h-10z"
126
+ * ```
127
+ */
128
+ declare function squarePath(s: number): string;
129
+ /**
130
+ * A cell's vertices around (0, 0), in the points' units: a hexagon of circumradius `size` (d3-hexbin's vertex
131
+ * order) or a square of side `size`. Add a bin's centre to each to outline that cell as a polygon.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * import { cellPoints } from "@sportsdataverse/sdvplot/bins";
136
+ *
137
+ * cellPoints("square", 10); // [[-5, -5], [5, -5], [5, 5], [-5, 5]]
138
+ * ```
139
+ */
140
+ declare function cellPoints(shape: BinShape, size: number): [number, number][];
141
+ /**
142
+ * A cell's relative SVG path, `hexagonPath(size)` or `squarePath(size)`, drawn with a `translate` to each bin centre.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * import { cellPath } from "@sportsdataverse/sdvplot/bins";
147
+ *
148
+ * cellPath("square", 10); // "m-5,-5h10v10h-10z"
149
+ * ```
150
+ */
151
+ declare function cellPath(shape: BinShape, size: number): string;
152
+ /**
153
+ * One binning API for both lattices: `binner({ radius: 15 })` is d3-hexbin's, `binner({ shape: "square", side: 15 })`
154
+ * squares, and `binner({ shape: "square", radius: 15, equalArea: true })` squares of side 15·√(3√3/2) ≈ 24.18,
155
+ * each the area of a radius-15 hexagon. Works on any x/y data, not just shots. Throws `InputError` on an unknown
156
+ * `shape` or a size that is not a positive finite number, naming the option passed.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * import { binner } from "@sportsdataverse/sdvplot/bins";
161
+ *
162
+ * const b = binner({ shape: "square", radius: 10, equalArea: true }); // side 16.1185…: a radius-10 hexagon's area
163
+ * // three Brooklyn shots of 2025-26 (sportsdataverse-data nba_stats_shots): the two at the rim share a square
164
+ * const shots = [
165
+ * { x_legacy: 0, y_legacy: 0 },
166
+ * { x_legacy: -1, y_legacy: 7 },
167
+ * { x_legacy: -44, y_legacy: 252 },
168
+ * ];
169
+ * b.bins(shots, { x: (s) => s.x_legacy, y: (s) => s.y_legacy }).map((c) => [c.x, c.y, c.length]);
170
+ * ```
171
+ */
172
+ declare function binner(o: BinnerOptions): Binner;
173
+
174
+ export { type BinOf, type BinShape, type Binner, type BinnerOptions, type Lattice, binner, cellPath, cellPoints, hexagonPath, hexbin, squarePath, squarebin };
package/dist/bins.js ADDED
@@ -0,0 +1,4 @@
1
+ export { binner, cellPath, cellPoints, hexagonPath, hexbin, squarePath, squarebin } from './chunk-C2CDY5OG.js';
2
+ import './chunk-E7G7VSLV.js';
3
+ //# sourceMappingURL=bins.js.map
4
+ //# sourceMappingURL=bins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"bins.js"}