Skip to main content

legendIcon: reactablefmtr's icon legend, drawn as inline SVG

AFC, 2024 regular season
TeamWinsLossesWin shareBand
15288.2%75-100%
11664.7%50-75%
10758.8%50-75%
41323.5%0-25%
13476.5%75-100%
8947.1%25-50%
51229.4%25-50%
41323.5%0-25%
Win-share band
0-25%25-50%50-75%75-100%
Ties count as games played
import { STANDINGS } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// Each team's win share falls in one of reactablefmtr's "batteries" bands; the legend under the table keys them.
const BANDS = ["0-25%", "25-50%", "50-75%", "75-100%"] as const;
const rows = STANDINGS.map((r) => {
const share = r.wins / (r.wins + r.losses + r.ties);
return {
team: r.team,
wins: r.wins,
losses: r.losses,
share,
band: BANDS[Math.min(3, Math.floor(share * 4))],
};
});
const spec = defineTable<(typeof rows)[number]>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.int("wins"),
c.int("losses"),
c.pct("share", { label: "Win share" }),
c.text("band", { label: "Band" }),
])
.legendIcon({ iconSet: "batteries", title: "Win-share band", footer: "Ties count as games played" })
.title("AFC, 2024 regular season")
.build();
await renderHTMLAsync(spec, rows);

Tags: decoration · legendIcon · add_icon_legend · reactablefmtr. All sdvtables examples.