Skip to main content

Function: surface()

surface(league, o?): object

Defined in: packages/sdvplot/src/plot/surface.ts:36

Plot marks + scales for a team-painted sporty surface. Only an unsupported league throws InputError; sporty's own errors (SportyError subclasses: unknown displayRange/unit, bad arcResolution) propagate unwrapped.

Parameters​

league​

"aaf" | "ahl" | "cfb" | "cricket" | "echl" | "mbb" | "milb" | "mlb" | "nba" | "nbagl" | "ncaa_baseball" | "ncaa_mhockey" | "ncaa_softball" | "ncaa_whockey" | "nfl" | "nhl" | "ohl" | "phf" | "pwhl" | "qmjhl" | "soccer" | "ufl" | "usfl" | "ushl" | "wbb" | "whl" | "wnba" | "xfl"

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 });