Skip to main content

Function: surfaceMark()

surfaceMark(scene, o?): Markish[]

Defined in: packages/sporty/src/plot.ts:80

Plot marks for a Scene, drawn through the plot's x/y scales (no projection): optional background, polygons, then text. Text font size = number height (fitBox[1] / 1.5) mapped through the y scale unless textFontSize overrides it. ariaDescription (default: the scene's league and sport, then "surface", such as "nba basketball surface") describes the polygons for assistive technology.

Parameters​

scene​

Scene

o?​

ariaDescription?​

string

textFontSize?​

number

Returns​

Markish[]

Example​

import * as Plot from "@observablehq/plot";
import { surface } from "@sportsdataverse/sporty";
import { surfaceMark } from "@sportsdataverse/sporty/plot";

const court = surface("tennis", "itf");
const [x0, y0, x1, y1] = court.bbox;
Plot.plot({
width: 300,
height: Math.round((300 * (y1 - y0)) / (x1 - x0)),
x: { domain: [x0, x1], axis: null },
y: { domain: [y0, y1], axis: null },
marks: surfaceMark(court),
});