Skip to main content

Function: statsBySide()

statsBySide(shots, binFt?, maxFt?, centreHalfWidth?): SideBin[]

Defined in: packages/sdvplot/src/shots/distance.ts:121

Left / centre / right of the hoop by distance (aggregate.ts:218-240): left is x < -centreHalfWidth, right is x > centreHalfWidth. The default 0 puts x == 0 in centre (main); false drops it, as master's binLeftRight did (src/utils/visuals/bin.ts:36-42). binFt and maxFt as for fgPctByDistance; a centreHalfWidth that is negative or not finite throws InputError.

Parameters​

shots​

readonly ShotRow[]

binFt?​

number = 1

maxFt?​

number = 35

centreHalfWidth?​

number | false

Returns​

SideBin[]

Example​

import { statsBySide } 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" },
];
statsBySide(shots, 3, 35, 7.5)[0];