Skip to main content

sparkline: an area, the inner-quartile band and the season's first and last values

AFC, 2024
TeamMargin, weeks 1-18
KCSparkline of 17 values: min -38, max 19, last -38; median line at 6; band over the inner quartiles67-38
LACSparkline of 17 values: min -23, max 33, last 14; median line at 7; band over the inner quartiles71214
DENSparkline of 17 values: min -31, max 38, last 38; median line at 9; band over the inner quartiles9-638
LVSparkline of 17 values: min -19, max 15, last -14; median line at -10; band over the inner quartiles-10-12-14
BUFSparkline of 17 values: min -25, max 37, last -7; median line at 6; band over the inner quartiles66-7
MIASparkline of 17 values: min -21, max 19, last -12; median line at -1; band over the inner quartiles-13-12
NYJSparkline of 17 values: min -26, max 21, last 12; median line at -3; band over the inner quartiles-3-1312
NESparkline of 17 values: min -33, max 16, last 7; median line at -5; band over the inner quartiles-567
import { AFC_WEEKS_2024, type AfcWeeks } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { renderHTMLAsync } from "@sportsdataverse/sdvtables/html";

// showArea fills under each unbroken run of weeks (the bye splits it); bandline shades the inner quartiles of the
// team's margins, statline marks the median, and labels prints the first and last weeks beside their points.
const spec = defineTable<AfcWeeks>()
.columns((c) => [
c.text("team"),
c.sparkline("margins", {
label: "Margin, weeks 1-18",
lineColor: "#15607A",
showArea: true,
bandline: "innerquartiles",
bandlineColor: "#15607A",
statline: "median",
labels: ["first", "last"],
chartWidth: 220,
}),
])
.title("AFC, 2024")
.build();
await renderHTMLAsync(spec, AFC_WEEKS_2024);

Tags: formatter · sparkline · react_sparkline · reactablefmtr · bandline · statline. All sdvtables examples.