Skip to main content

Function: SurfaceBackdrop()

SurfaceBackdrop(props): ReactElement

Defined in: packages/sdvplot/src/react/recharts.tsx:168

A team-painted court, field or rink under a Recharts chart's series: place it as a child of the chart (before the series), as Recharts 3 renders any element there (<Customized> is deprecated). The surface is drawn in the numeric axes' units: set both axes' domain to the surface's bbox (sporty's surface(...).bbox) to fill the plot area, or to any range in those units to show part of it. recharts (3.8 or later) and @sportsdataverse/sporty load when it first renders, never with sdvplot/react; either missing throws OptionalDependencyError then. A server render draws nothing (it loads on the client).

Parameters​

props​

SurfaceBackdropProps

Returns​

ReactElement

Example​

import { SurfaceBackdrop } from "@sportsdataverse/sdvplot/react";
import { surface } from "@sportsdataverse/sporty";
import { Scatter, ScatterChart, XAxis, YAxis } from "recharts";

const [x0, y0, x1, y1] = surface("basketball", "nba", { displayRange: "defense" }).bbox;
<ScatterChart width={500} height={470}>
<XAxis type="number" dataKey="x" domain={[x0, x1]} hide />
<YAxis type="number" dataKey="y" domain={[y0, y1]} hide />
<SurfaceBackdrop league="nba" team="DEN" displayRange="defense" />
<Scatter data={[{ x: 0, y: 5.25 }]} />
</ScatterChart>;