Svelte + LayerChart: points scored and allowed in 2024, each team drawn as its quarterback's headshot
With JavaScript on, Svelte (with LayerChart) draws this figure here.
[
{
"team": "KC",
"pf": 385,
"pa": 326,
"qb_espn_id": "3139477",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/3139477.png",
"aspect": 1.3761467889908257
},
{
"team": "LAC",
"pf": 402,
"pa": 301,
"qb_espn_id": "4038941",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/4038941.png",
"aspect": 1.3761467889908257
},
{
"team": "DEN",
"pf": 425,
"pa": 311,
"qb_espn_id": "4426338",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/4426338.png",
"aspect": 1.3761467889908257
},
{
"team": "LV",
"pf": 309,
"pa": 434,
"qb_espn_id": "4038524",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/4038524.png",
"aspect": 1.3761467889908257
},
{
"team": "BUF",
"pf": 525,
"pa": 368,
"qb_espn_id": "3918298",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/3918298.png",
"aspect": 1.3761467889908257
},
{
"team": "MIA",
"pf": 345,
"pa": 364,
"qb_espn_id": "4241479",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/4241479.png",
"aspect": 1.3761467889908257
},
{
"team": "NYJ",
"pf": 338,
"pa": 404,
"qb_espn_id": "8439",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/8439.png",
"aspect": 1.3761467889908257
},
{
"team": "NE",
"pf": 289,
"pa": 417,
"qb_espn_id": "4431452",
"headshot": "https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/4431452.png",
"aspect": 1.3761467889908257
}
]import { STANDINGS } from "@sportsdataverse/examples/data";
import { HEADSHOT_ASPECT, headshotUrl } from "@sportsdataverse/sdvplot";
// The STANDINGS teams' points for and against, and each starting quarterback's ESPN athlete id.
const rows = STANDINGS.map(({ team, pf, pa, qb_espn_id }) => ({ team, pf, pa, qb_espn_id }));
// In the browser: examples/snippets/svelte/QbHeadshots.svelte, mounted with these props (Svelte's mount()).
export const browser = {
lib: "svelte",
component: "QbHeadshots",
props: { rows, width: 560, height: 380 },
label:
"Points for against points allowed for eight 2024 AFC teams, each drawn as its starting quarterback's ESPN headshot",
} as const;
// Svelte draws only in a browser here; without JavaScript the page shows each headshot the chart draws, at its aspect.
rows.map((r) => ({
...r,
headshot: headshotUrl(r.qb_espn_id, "nfl"),
aspect: HEADSHOT_ASPECT,
}));
Tags: svelte · layerchart · HeadshotMark · nfl. All sdvplot examples.