Skip to main content

colorPills: a pill in each team's colour

AFC, 2024
TeamWins
KC15
LAC11
DEN10
LV4
BUF13
MIA8
NYJ5
NE4
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// reactablefmtr pill_buttons(color_ref): team + league (or colorRef, a colour column) give each row its own pill
// colour; the text turns black or white to stay readable.
const spec = defineTable<Standing>()
.columns((c) => [
c.text("team"),
c.colorPills("wins", { label: "Wins", team: "team", league: "nfl", domain: [0, 17], digits: 0 }),
])
.title("AFC, 2024")
.build();
await renderHTMLAsync(spec, STANDINGS);

Tags: formatter · colorPills · pill_buttons · reactablefmtr · nfl. All sdvtables examples.