Skip to main content

colorRanks: color_tiles options (span, bias, evenBreaks, showText)

AFC, 2024
TeamPFPASRS rankWins
KC3853261015
LAC402301911
DEN425311810
LV309434264
BUF525368413
MIA345364218
NYJ338404245
NE289417294
import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// span puts points for and against on one scale; bias spreads the high end; evenBreaks deals the palette out in
// equal-count buckets; showText: false keeps only the colour.
const spec = defineTable<Standing>()
.columns((c) => [
c.text("team"),
c.colorRanks("pf", { label: "PF", span: ["pf", "pa"], bias: 1.5, palette: ["#FFFFFF", "#15607A"] }),
c.colorRanks("pa", { label: "PA", span: ["pf", "pa"], bias: 1.5, palette: ["#FFFFFF", "#15607A"] }),
c.colorRanks("srs_rank", { label: "SRS rank", evenBreaks: true }),
c.colorRanks("wins", { label: "Wins", showText: false, reverse: true }),
])
.title("AFC, 2024")
.build();
await renderHTMLAsync(spec, STANDINGS);

Tags: formatter · colorRanks · color_tiles · color_scales · reactablefmtr. All sdvtables examples.