Function: surface()
surface(
league,o?):object
Defined in: packages/sdvplot/src/plot/surface.ts:42
Plot marks + scales for a team-painted sporty surface, for any key of SURFACES. An unsupported key, or a team on a key
without team identities, throws InputError; sporty's own
errors (SportyError subclasses: unknown displayRange/unit, bad arcResolution) propagate unwrapped.
Parameters
league
"aaf" | "ahl" | "ajhl" | "bchl" | "cchl" | "cebl" | "cfb" | "cfl" | "chl" | "cricket" | "easl" | "echl" | "f1" | "fiba" | "gojhl" | "iihf" | "kijhl" | "lba" | "mbb" | "mhl" | "milb" | "mjhl" | "mlb" | "nba" | "nbagl" | "nbl" | "ncaa_baseball" | "ncaa_mhockey" | "ncaa_softball" | "ncaa_whockey" | "nfl" | "nhl" | "nojhl" | "ohl" | "ojhl" | "phf" | "pwhl" | "qmjhl" | "sjhl" | "soccer" | "sphl" | "ufl" | "usfl" | "ushl" | "vijhl" | "wbb" | "whl" | "wnba" | "xfl" | string & object
o?
SurfaceOpts = {}
Returns
object
marks
marks:
Markish[]
scales
scales:
object
scales.aspectRatio
aspectRatio:
1
scales.x
x:
object
scales.x.axis
axis:
null
scales.x.domain
domain: [
number,number]
scales.y
y:
object
scales.y.axis
axis:
null
scales.y.domain
domain: [
number,number]
scene
scene:
Scene
Example
import * as Plot from "@observablehq/plot";
import { loadLeague } from "@sportsdataverse/sdvplot";
import { surface } from "@sportsdataverse/sdvplot/plot";
await loadLeague("nhl");
// arcResolution: points per arc (default 200); 24 is plenty at 480 px and keeps the SVG small
const rink = surface("nhl", { team: "BOS", displayRange: "offense", arcResolution: 24 });
Plot.plot({ ...rink.scales, width: 480, marks: rink.marks });