Skip to main content

Function: binShots()

binShots(shots, cell): CellBin[]

Defined in: packages/sdvplot/src/shots/aggregate.ts:81

Bin shots in DATA space (legacy tenths), dropping off-court points (aggregate.ts:86-104) and points with a non-finite coordinate (main lets y_legacy = Infinity through). cell is a hexagon radius (10 = a 1 ft hex) or any binner lattice, e.g. { shape: "square", side: 15 }. Bins come out in first-seen order (d3-hexbin's, for hexagons).

Parameters​

shots​

readonly ShotRow[]

cell​

number | BinnerOptions

Returns​

CellBin[]

Example​

import { binShots } from "@sportsdataverse/sdvplot/shots";

// Brooklyn shots from the sportsdataverse-data nba_stats_shots release, 2025-26
const shots = [
{ x_legacy: -1, y_legacy: 7, shot_distance: 1, shot_value: 2, shot_result: "Made" },
{ x_legacy: 0, y_legacy: 0, shot_distance: 0, shot_value: 2, shot_result: "Missed" },
{ x_legacy: -44, y_legacy: 252, shot_distance: 26, shot_value: 3, shot_result: "Made" },
];
binShots(shots, 15);
binShots(shots, { shape: "square", side: 15 });