Skip to main content

legendDiscrete: a key of named colours

Final regular-season game
WonLost
AFC, 2024
TeamQbWeek 18
Patrick MahomesL
Justin HerbertW
Bo NixW
Gardner MinshewL
Josh AllenL
Tua TagovailoaL
Aaron RodgersW
Drake MayeW
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

const spec = defineTable<Standing>()
.columns((c) => [
c.logo("team", { league: "nfl" }),
c.text("qb"),
c.colorResults("result_last", { label: "Week 18" }),
])
.legendDiscrete({ Won: "#5DA271", Lost: "#C84630" }, { heading: "Final regular-season game" })
.title("AFC, 2024")
.build();
await renderHTMLAsync(spec, STANDINGS);

Tags: decoration · legendDiscrete · gt_legend_discrete · gt_centered_legend. All sdvtables examples.