sdvplot-js docs · View source

Win-probability scrubber

The question: which plays decided the game? ESPN publishes a win probability after every play of an NFL or college football game. Drawn over the game and paired with the play-by-play, it shows when the game turned, and the biggest jumps name the plays that turned it.

The workflow: one ESPN summary request holds everything. sportsdataverse-js splits it into sections (sdv.nfl.espnNflSummary({ event_id, parsed: true, section }) in Node; here the same parser, parseEndpoint("espn", "summary", raw, section), on the same JSON in your browser): header for the teams and the final score, winprobability for one row per play (the home team's chance and the play's id), and drive_plays for the plays themselves. The page joins the two on the play id, colours the home and away halves with sdvplot's matchupColors, puts each team's logo on its side of 50%, and hovers the nearest play with nearestHover.

The snapshot is the 2024 NFL season opener, Baltimore at Kansas City on 5 September 2024 (Kansas City won 27-20; ESPN event 401671789). Tick Fetch live from ESPN to load any NFL or college football game by its ESPN event id (the number in an espn.com game URL), or arrive here from a card on the live scoreboard.

Drag Play to scrub through the game: the rule and the panel under the chart follow it. Hover the chart for the nearest play.

The plays that decided it

The eight plays that moved the win probability most, either way. A swing is in percentage points of the home team's chance.

What to take from it

Script it in Node: the same three sections come from sdv.nfl.espnNflSummary({ event_id: 401671789, parsed: true, section: "winprobability" }); see sdv-js's cross-league tutorial for the summary sections. The Linked interactivity notebook covers nearestHover and tooltip in depth.