Skip to main content

Function: sizeCells()

sizeCells(cells, o): CellSizes

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

Frequency size for each cell (the dual encoding's size half; colour is diffScale), on the lattice's full cell size R (a hexagon's radius, or a square's side; pass the index itself: sizeCells(cells, index)). "sqrt-p95" (default, main hexShotChart.ts:65-81): a sqrt scale of attempts, capped at the 95th percentile of all the cells so one busy rim cell does not shrink the rest; area follows attempts for either shape. "linear-cap" (master Hexagon/index.js:22-30): attempts in tenths, capped at R. Under either rule a cell under minAttempts (default 2) is not drawn, and the drawn size is fill (default 0.88) times the rule's, so the busiest cells stop short of their neighbours. main drew every cell up to full size: { minAttempts: 1, fill: 1 }; master is { rule: "linear-cap", fill: 1 }. Throws InputError on a minAttempts that is not a finite number, or a fill outside (0, 1].

Parameters​

cells​

readonly object[]

o​

SizeCellsOptions

Returns​

CellSizes

Example​

import { binShots, sizeCells } 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" },
];
sizeCells(binShots(shots, 15), { radius: 15 }).r; // the 2-attempt rim cell at 0.88 of full size, the 1-attempt three not drawn