legendIcon: reactablefmtr's icon legend, drawn as inline SVG
| Team | Wins | Losses | Win share | Band |
|---|---|---|---|---|
![]() | 15 | 2 | 88.2% | 75-100% |
![]() | 11 | 6 | 64.7% | 50-75% |
![]() | 10 | 7 | 58.8% | 50-75% |
![]() | 4 | 13 | 23.5% | 0-25% |
![]() | 13 | 4 | 76.5% | 75-100% |
![]() | 8 | 9 | 47.1% | 25-50% |
![]() | 5 | 12 | 29.4% | 25-50% |
![]() | 4 | 13 | 23.5% | 0-25% |
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.







