Skip to main content

sparkbar: points scored each week, the best week labelled

AFC, 2024
TeamPoints, weeks 1-18
KCBar chart of 17 values: min 0, max 30, last 030
LACBar chart of 17 values: min 10, max 40, last 3440
DENBar chart of 17 values: min 6, max 41, last 3841
LVBar chart of 17 values: min 9, max 26, last 2026
BUFBar chart of 17 values: min 10, max 48, last 1648
MIABar chart of 17 values: min 3, max 34, last 2034
NYJBar chart of 17 values: min 6, max 32, last 3232
NEBar chart of 17 values: min 3, max 25, last 2325
import { AFC_WEEKS_2024, type AfcWeeks } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// reactablefmtr react_sparkbar: a bar per week standing on zero; the bye leaves an empty slot. highlightBars recolours
// the best week, labels prints its value above the bar, and the table's text colour draws the label.
const spec = defineTable<AfcWeeks>()
.columns((c) => [
c.text("team"),
c.sparkbar("points", {
label: "Points, weeks 1-18",
highlightBars: { max: "#FA8C00" },
labels: ["max"],
chartWidth: 180,
}),
])
.title("AFC, 2024")
.build();
await renderHTMLAsync(spec, AFC_WEEKS_2024);

Tags: kind · sparkbar · react_sparkbar · reactablefmtr · nfl. All sdvtables examples.