binner
[
[
0,
0,
2
],
[
-48.355646932059386,
257.89678363765006,
1
]
]import { binner } from "@sportsdataverse/sdvplot/bins";
const b = binner({ shape: "square", radius: 10, equalArea: true }); // side 16.1185…: a radius-10 hexagon's area
// three Brooklyn shots of 2025-26 (sportsdataverse-data nba_stats_shots): the two at the rim share a square
const shots = [
{ x_legacy: 0, y_legacy: 0 },
{ x_legacy: -1, y_legacy: 7 },
{ x_legacy: -44, y_legacy: 252 },
];
b.bins(shots, { x: (s) => s.x_legacy, y: (s) => s.y_legacy }).map((c) => [c.x, c.y, c.length]);
Tags: docstring · binner. All sdvplot examples.