sdvplot-js docs · View source

Player trend explorer

The question: is a player trending up or down, and what did they do over a stretch you pick? Season averages hide form. A game-by-game line with a rolling average shows the streaks, and brushing a stretch of dates gives that window's averages, the numbers a fantasy manager or a beat writer wants.

The workflow: sportsdataverse-js reads ESPN's game log (sdv.nba.espnNbaPlayerGamelog({ athlete_id, season, parsed: true }) in Node; the same parser on the same JSON here). The parser gives one row per game: the season block (season_type_name), the event id and fourteen stats as stat_0 to stat_13. The rest is in the same response beside the rows: names says which stat is which (stat_13 is points), and events holds each game's date, opponent and result. The page joins the two on the event id, draws the chosen stat with sdvplot (the player's team colour and ESPN headshot), and links a 1-D brushFilter on the dates to an sdvtables table of the games.

The snapshot is LeBron James's 2023-24 game log (ESPN athlete 1966, season=2024): one capture shared with sdv-js's player form tutorial, byte for byte. Tick Fetch live from ESPN to load any NBA or WNBA player by ESPN athlete id (the number in an espn.com player URL); leave Season blank for ESPN's current one.

Drag across the chart to brush a stretch of games: the table keeps those games and the line under the table gives their averages. Click outside the brush to clear it.

: points, rebounds and assists in minutes a game.

What to take from it

Script it in Node: sdv-js's player form tutorial draws the same season as a static chart with meanLines and headshots. The Linked interactivity notebook covers brushFilter in depth.