Function: toSurfaceFrame()
toSurfaceFrame<
R>(rows,o):R&object[]
Defined in: packages/sporty/src/frames.ts:141
Move data rows into a surface's frame. Returns new rows (inputs untouched) with surface_x/surface_y
(or the names in out) added; missing or non-numeric inputs give null.
x/y name the input columns (default x/y, or x_legacy/y_legacy for "nba-legacy" and
"nba-legacy-vertical"). The frame sees
a view { x: row[xCol], y: row[yCol] }.
Type Parameters
R
R extends Row
Parameters
rows
readonly R[]
o
from
Frame | "nba-legacy" | "nba-legacy-vertical" | "hockeytech" | "espn-football-0-100"
out?
{ x?: string; y?: string; }
out.x?
string
out.y?
string
x?
string
y?
string
Returns
R & object[]
Example
import { toSurfaceFrame } from "@sportsdataverse/sporty";
// two stats.nba.com shots (shotchartdetail, Lakers at Nuggets, 2023-10-24, game 0022300061, events 510 and 530):
// x_legacy / y_legacy are LOC_X / LOC_Y, tenths of a foot from the hoop
toSurfaceFrame(
[
{ x_legacy: -53, y_legacy: 285, team: "LAL", player: "LeBron James" },
{ x_legacy: -136, y_legacy: 214, team: "DEN", player: "Nikola Jokić" },
],
{ from: "nba-legacy" },
);