{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0",
   "metadata": {},
   "source": [
    "# reactable formatters\n",
    "\n",
    "[reactablefmtr](https://kcuilla.github.io/reactablefmtr/) is the R package that dresses up reactable cells: data bars,\n",
    "color tiles and scales, pill buttons, icon sets, merged columns, highlights and bubble grids. `sdvplot.reactable`\n",
    "ports its cell formatters to [reactable-py](https://machow.github.io/reactable-py/) as ordinary `reactable.Column`\n",
    "objects, with reactablefmtr's semantics and defaults (the same color ramps, buckets and layouts), and adds the\n",
    "SportsDataverse parts: any formatter that takes a color column also takes a team column and a league, filling each cell\n",
    "in that team's color with text that stays readable, and data bars and merged columns can carry the row's logo,\n",
    "headshot or wordmark. Icons are inline SVG and tooltips are the cell's `title`, so the tables need no Font Awesome and\n",
    "no extra JavaScript.\n",
    "\n",
    "Each formatter takes the frame you pass to `Reactable` (it reads ranges, buckets and team colors from it) and the\n",
    "column's `id`. Every section below is one formatter on real data from sportsdataverse-py, across the NFL, NBA, WNBA,\n",
    "NHL, MLB and college sports. The [reactable](reactable.md) cookbook covers the logo, headshot and team-color columns\n",
    "these build on."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl\n",
    "import sportsdataverse.cfb as cfb\n",
    "import sportsdataverse.mbb as mbb\n",
    "import sportsdataverse.mlb as mlb\n",
    "import sportsdataverse.nba as nba\n",
    "import sportsdataverse.nfl as nfl\n",
    "import sportsdataverse.nhl as nhl\n",
    "import sportsdataverse.wnba as wnba\n",
    "from reactable import Column, Reactable, embed_css\n",
    "\n",
    "import sdvplot\n",
    "from sdvplot.reactable import (\n",
    "    reactable_sdv_bubble_grid,\n",
    "    reactable_sdv_color_scales,\n",
    "    reactable_sdv_color_tiles,\n",
    "    reactable_sdv_data_bars,\n",
    "    reactable_sdv_highlight,\n",
    "    reactable_sdv_icon_assign,\n",
    "    reactable_sdv_icon_sets,\n",
    "    reactable_sdv_icon_trend,\n",
    "    reactable_sdv_logos,\n",
    "    reactable_sdv_merge_column,\n",
    "    reactable_sdv_pill_buttons,\n",
    ")\n",
    "\n",
    "NFL_SEASON = 2025  # nflverse and cfbfastR name a season by the year it starts\n",
    "SEASON = 2026  # the 2026 MLB and WNBA seasons, and the 2025-26 NBA, NHL and college basketball seasons\n",
    "embed_css()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2",
   "metadata": {},
   "source": [
    "## 1. Data bars in team colors: NBA wins\n",
    "\n",
    "`reactable_sdv_data_bars` draws each value as a bar, its length the value's share of the column's largest. With\n",
    "`team_col` and `league` every bar takes its team's primary color, the number inside switches to white on a dark bar,\n",
    "and `mark=\"logo\"` puts the team's logo at the end of the bar. `tooltip=True` gives each cell a hover title. The data is\n",
    "the 2025-26 NBA regular season, summed from ESPN team box scores of the regular-season schedule's games (the NBA Cup final, played in December, is not one)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# regular-season games only: season_type 2 also holds the NBA Cup final, which does not count in the standings\n",
    "nba_schedule = nba.load_nba_schedule(seasons=[SEASON]).filter(\n",
    "    (pl.col(\"season_type\") == 2) & (pl.col(\"type_abbreviation\") == \"STD\")\n",
    ")\n",
    "nba_season = (\n",
    "    nba.load_nba_team_boxscore(seasons=[SEASON])\n",
    "    .filter(pl.col(\"game_id\").is_in(nba_schedule[\"game_id\"].implode()))\n",
    "    .group_by(\"team_abbreviation\", \"team_display_name\", maintain_order=True)\n",
    "    .agg(gp=pl.len(), wins=pl.col(\"team_winner\").sum())\n",
    ")\n",
    "assert nba_season[\"gp\"].max() <= 82, \"more games than an 82-game regular season\"\n",
    "nba_teams = (\n",
    "    nba_season.filter(pl.col(\"gp\") > 10)\n",
    "    .sort([\"wins\", \"team_abbreviation\"], descending=[True, False])\n",
    "    .head(12)\n",
    "    .drop(\"gp\")\n",
    ")\n",
    "Reactable(\n",
    "    nba_teams,\n",
    "    columns=[\n",
    "        Column(id=\"team_abbreviation\", show=False),\n",
    "        Column(id=\"team_display_name\", name=\"Team\", min_width=190),\n",
    "        reactable_sdv_data_bars(\n",
    "            nba_teams,\n",
    "            team_col=\"team_abbreviation\",\n",
    "            league=\"nba\",\n",
    "            mark=\"logo\",\n",
    "            mark_height=22,\n",
    "            bar_height=24,\n",
    "            round_edges=True,\n",
    "            tooltip=True,\n",
    "            id=\"wins\",\n",
    "            name=\"Wins\",\n",
    "            min_width=320,\n",
    "        ),\n",
    "    ],\n",
    "    default_page_size=12,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4",
   "metadata": {},
   "source": [
    "## 2. Color tiles: NFL offense and defense by EPA\n",
    "\n",
    "`reactable_sdv_color_tiles` fills each cell with a rounded tile on a color ramp: reactablefmtr's default\n",
    "blue-white-orange, or any hex colors you give, here red to green. `number_fmt` takes a format spec (or a function);\n",
    "the defensive column reverses the ramp because less allowed is better. The team column is tiled too, in each team's\n",
    "own color. Expected points added per play come from nflverse's weekly team stats."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5",
   "metadata": {},
   "outputs": [],
   "source": [
    "weeks = nfl.load_nfl_team_stats([NFL_SEASON]).filter(pl.col(\"season_type\") == \"REG\")\n",
    "plays = pl.col(\"attempts\") + pl.col(\"sacks_suffered\") + pl.col(\"carries\")\n",
    "\n",
    "\n",
    "def epa_per_play(by):\n",
    "    return weeks.group_by(team=by, maintain_order=True).agg(\n",
    "        epa=(pl.col(\"passing_epa\") + pl.col(\"rushing_epa\")).sum() / plays.sum()\n",
    "    )\n",
    "\n",
    "\n",
    "nfl_epa = (\n",
    "    epa_per_play(pl.col(\"team\"))\n",
    "    .join(epa_per_play(pl.col(\"opponent_team\")), on=\"team\", suffix=\"_allowed\")\n",
    "    .with_columns(net=pl.col(\"epa\") - pl.col(\"epa_allowed\"))\n",
    "    .sort(\"net\", descending=True)\n",
    "    .head(16)\n",
    ")\n",
    "red_green = [\"#d7301f\", \"#ffffbf\", \"#1a9850\"]\n",
    "Reactable(\n",
    "    nfl_epa,\n",
    "    columns=[\n",
    "        reactable_sdv_color_tiles(nfl_epa, team_col=\"team\", league=\"nfl\", id=\"team\", name=\"Team\", width=80),\n",
    "        reactable_sdv_color_tiles(nfl_epa, colors=red_green, number_fmt=\"+.3f\", id=\"epa\", name=\"Offense\"),\n",
    "        reactable_sdv_color_tiles(\n",
    "            nfl_epa, colors=red_green[::-1], number_fmt=\"+.3f\", id=\"epa_allowed\", name=\"Defense allowed\"\n",
    "        ),\n",
    "        reactable_sdv_color_tiles(nfl_epa, colors=red_green, number_fmt=\"+.3f\", bold_text=True, id=\"net\", name=\"Net\"),\n",
    "    ],\n",
    "    default_page_size=16,\n",
    "    compact=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6",
   "metadata": {},
   "source": [
    "## 3. Color scales: the MLB standings\n",
    "\n",
    "`reactable_sdv_color_scales` is the same scale without the tile: it styles the whole cell, so the table keeps its\n",
    "grid. Run differential is colored on reactablefmtr's default ramp (blue at the bottom, orange at the top), and the\n",
    "team column carries each club's primary color at 85% opacity, its text still readable. The standings are ESPN's for\n",
    "the 2026 season."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7",
   "metadata": {},
   "outputs": [],
   "source": [
    "mlb_table = (\n",
    "    mlb.espn_mlb_standings(season=SEASON)\n",
    "    .with_columns(pl.col(\"wins\", \"losses\", \"point_differential\").cast(pl.Int64))\n",
    "    .sort([\"win_percent\", \"team_abbreviation\"], descending=[True, False])\n",
    "    .select(team=\"team_abbreviation\", name=\"team_display_name\", w=\"wins\", l=\"losses\", diff=\"point_differential\")\n",
    "    .head(15)\n",
    ")\n",
    "Reactable(\n",
    "    mlb_table,\n",
    "    columns=[\n",
    "        reactable_sdv_color_scales(mlb_table, team_col=\"team\", league=\"mlb\", opacity=0.85, id=\"team\", name=\"\"),\n",
    "        Column(id=\"name\", name=\"Team\", min_width=180),\n",
    "        Column(id=\"w\", name=\"W\"),\n",
    "        Column(id=\"l\", name=\"L\"),\n",
    "        reactable_sdv_color_scales(mlb_table, number_fmt=\"+d\", id=\"diff\", name=\"Run diff.\"),\n",
    "    ],\n",
    "    default_page_size=15,\n",
    "    compact=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8",
   "metadata": {},
   "source": [
    "## 4. Pill buttons: the WNBA's leading scorers\n",
    "\n",
    "`reactable_sdv_pill_buttons` sets each value in a rounded pill. Numbers ramp across `colors`; text takes the first\n",
    "color, or, with `team_col`, the row's team color. Here the team abbreviation sits in a team-colored pill and points\n",
    "per game ramp from gray to orange. Per-game averages come from ESPN player box scores of the 2026 regular season."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9",
   "metadata": {},
   "outputs": [],
   "source": [
    "schedule = wnba.load_wnba_schedule(seasons=[SEASON]).filter(\n",
    "    (pl.col(\"season_type\") == 2) & (pl.col(\"type_abbreviation\") == \"STD\")\n",
    ")\n",
    "wnba_players = wnba.load_wnba_player_boxscore(seasons=[SEASON]).filter(\n",
    "    pl.col(\"game_id\").is_in(schedule[\"game_id\"].implode()) & ~pl.col(\"did_not_play\")\n",
    ")\n",
    "scorers = (\n",
    "    wnba_players.sort(\"game_date\")\n",
    "    .group_by(\"athlete_id\", \"athlete_display_name\", maintain_order=True)\n",
    "    .agg(team=pl.col(\"team_abbreviation\").last(), gp=pl.len(), ppg=pl.col(\"points\").mean().round(1))\n",
    "    .filter(pl.col(\"gp\") >= 20)\n",
    "    .sort([\"ppg\", \"athlete_display_name\"], descending=[True, False])\n",
    "    .head(12)\n",
    ")\n",
    "Reactable(\n",
    "    scorers,\n",
    "    columns=[\n",
    "        Column(id=\"athlete_id\", show=False),\n",
    "        Column(id=\"athlete_display_name\", name=\"Player\", min_width=180),\n",
    "        reactable_sdv_pill_buttons(scorers, team_col=\"team\", league=\"wnba\", bold_text=True, id=\"team\", name=\"Team\"),\n",
    "        Column(id=\"gp\", name=\"GP\"),\n",
    "        reactable_sdv_pill_buttons(scorers, colors=[\"#d9d9d9\", \"#fa4d00\"], number_fmt=\".1f\", id=\"ppg\", name=\"PPG\"),\n",
    "    ],\n",
    "    default_page_size=12,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10",
   "metadata": {},
   "source": [
    "## 5. Icon sets: NHL goal differential\n",
    "\n",
    "`reactable_sdv_icon_sets` cuts the column into as many quantile buckets as `icons` (and as `colors`) and puts the\n",
    "bucket's icon beside each value. Three buckets of goal differential in the final 2025-26 NHL standings get a down\n",
    "arrow, a dash and an up arrow. The icons are inline SVG: circle, square, diamond, triangles, arrows, chevrons, star,\n",
    "check, x, flag, minus, plus, heart and person."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11",
   "metadata": {},
   "outputs": [],
   "source": [
    "nhl_table = (\n",
    "    nhl.nhl_standings(\"2026-04-16\")\n",
    "    .select(\n",
    "        team=\"team_abbrev_default\",\n",
    "        name=\"team_name_default\",\n",
    "        pts=\"points\",\n",
    "        gf=\"goal_for\",\n",
    "        ga=\"goal_against\",\n",
    "        diff=\"goal_differential\",\n",
    "    )\n",
    "    .sort([\"pts\", \"team\"], descending=[True, False])\n",
    ")\n",
    "Reactable(\n",
    "    nhl_table,\n",
    "    columns=[\n",
    "        reactable_sdv_logos(league=\"nhl\", id=\"team\", name=\"\", height=24, width=60),\n",
    "        Column(id=\"name\", name=\"Team\", min_width=170),\n",
    "        Column(id=\"pts\", name=\"PTS\"),\n",
    "        Column(id=\"gf\", name=\"GF\"),\n",
    "        Column(id=\"ga\", name=\"GA\"),\n",
    "        reactable_sdv_icon_sets(\n",
    "            nhl_table,\n",
    "            icons=(\"arrow-down\", \"minus\", \"arrow-up\"),\n",
    "            colors=(\"#c0392b\", \"#9e9e9e\", \"#1e8449\"),\n",
    "            number_fmt=\"+d\",\n",
    "            id=\"diff\",\n",
    "            name=\"Goal diff.\",\n",
    "        ),\n",
    "    ],\n",
    "    default_page_size=10,\n",
    "    compact=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12",
   "metadata": {},
   "source": [
    "## 6. Icon assign: SEC wins, one dot a win\n",
    "\n",
    "`reactable_sdv_icon_assign` repeats an icon up to the column's largest value and fills as many as the row's value:\n",
    "here each SEC team's 2025 wins as filled circles out of the most any team won, with the number to the right. With\n",
    "`buckets=` it instead fills the row's quantile bucket out of that many icons. Each row reads to a screen reader as an\n",
    "image labelled, for example, \"10 out of 13\". Wins are counted from cfbfastR's schedule of completed games."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13",
   "metadata": {},
   "outputs": [],
   "source": [
    "games = cfb.load_cfb_schedule(NFL_SEASON).filter(pl.col(\"completed\"))\n",
    "results = pl.concat(\n",
    "    [\n",
    "        games.select(team_id=\"home_id\", team=\"home_team\", conference=\"home_conference\", won=\"home_winner\"),\n",
    "        games.select(team_id=\"away_id\", team=\"away_team\", conference=\"away_conference\", won=\"away_winner\"),\n",
    "    ],\n",
    "    how=\"vertical_relaxed\",\n",
    ")\n",
    "sec = (\n",
    "    results.filter(pl.col(\"conference\") == \"SEC\")\n",
    "    .group_by(\"team_id\", \"team\")\n",
    "    .agg(wins=pl.col(\"won\").sum(), games=pl.len())\n",
    "    .sort([\"wins\", \"team\"], descending=[True, False])\n",
    "    .with_columns(logo=pl.col(\"team_id\"))\n",
    "    .select(\"logo\", \"team\", \"wins\", \"games\")\n",
    ")\n",
    "Reactable(\n",
    "    sec,\n",
    "    columns=[\n",
    "        reactable_sdv_logos(league=\"cfb\", id=\"logo\", name=\"\", id_system=\"espn\", height=24, width=60),\n",
    "        Column(id=\"team\", name=\"Team\", min_width=140),\n",
    "        reactable_sdv_icon_assign(\n",
    "            sec, icon_size=11, fill_color=\"#461d7c\", show_values=\"right\", id=\"wins\", name=\"Wins\", min_width=260\n",
    "        ),\n",
    "        Column(id=\"games\", name=\"Games\"),\n",
    "    ],\n",
    "    default_page_size=16,\n",
    "    compact=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14",
   "metadata": {},
   "source": [
    "## 7. Icon trend: NFL win changes, 2024 to 2025\n",
    "\n",
    "`reactable_sdv_icon_trend` marks each change with an up icon, a down icon or a dash, and colors the number to match\n",
    "(reactablefmtr's `icon_trend_indicator`). `icons` picks the shape: arrow, chevron or triangle. Regular-season wins\n",
    "come from nflverse's schedules of both seasons."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15",
   "metadata": {},
   "outputs": [],
   "source": [
    "nfl_games = nfl.load_nfl_schedule([NFL_SEASON - 1, NFL_SEASON]).filter(\n",
    "    (pl.col(\"game_type\") == \"REG\") & pl.col(\"result\").is_not_null()\n",
    ")\n",
    "team_wins = (\n",
    "    pl.concat(\n",
    "        [\n",
    "            nfl_games.select(\"season\", team=\"home_team\", win=pl.col(\"result\") > 0),\n",
    "            nfl_games.select(\"season\", team=\"away_team\", win=pl.col(\"result\") < 0),\n",
    "        ]\n",
    "    )\n",
    "    .group_by(\"team\", \"season\")\n",
    "    .agg(wins=pl.col(\"win\").sum())\n",
    "    .pivot(\"season\", index=\"team\", values=\"wins\")\n",
    "    .rename({str(NFL_SEASON - 1): \"before\", str(NFL_SEASON): \"after\"})\n",
    "    .with_columns(change=pl.col(\"after\") - pl.col(\"before\"))\n",
    "    .sort([\"change\", \"team\"], descending=[True, False])\n",
    ")\n",
    "Reactable(\n",
    "    team_wins,\n",
    "    columns=[\n",
    "        reactable_sdv_logos(league=\"nfl\", id=\"team\", name=\"\", include_name=True, height=24, min_width=100),\n",
    "        Column(id=\"before\", name=str(NFL_SEASON - 1)),\n",
    "        Column(id=\"after\", name=str(NFL_SEASON)),\n",
    "        reactable_sdv_icon_trend(\n",
    "            team_wins, icons=\"triangle\", number_fmt=\"+d\", show_zero_label=True, id=\"change\", name=\"Change\"\n",
    "        ),\n",
    "    ],\n",
    "    default_page_size=12,\n",
    "    compact=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "16",
   "metadata": {},
   "source": [
    "## 8. Merge column with headshots: the WNBA scorers again\n",
    "\n",
    "`reactable_sdv_merge_column` shows a second column's value beside or below each value, so each player's team sits\n",
    "under her name in small gray text. With `mark=\"headshot\"` (and `mark_col` naming the ESPN athlete id) the player's\n",
    "photo leads the cell. The merged and id columns are hidden."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17",
   "metadata": {},
   "outputs": [],
   "source": [
    "scorers_named = scorers.join(sdvplot.teams(\"wnba\").select(team=\"abbr\", team_name=\"name\"), on=\"team\", how=\"left\")\n",
    "Reactable(\n",
    "    scorers_named,\n",
    "    columns=[\n",
    "        reactable_sdv_merge_column(\n",
    "            scorers_named,\n",
    "            merged_name=\"team_name\",\n",
    "            merged_position=\"below\",\n",
    "            mark=\"headshot\",\n",
    "            mark_col=\"athlete_id\",\n",
    "            league=\"wnba\",\n",
    "            mark_height=40,\n",
    "            id=\"athlete_display_name\",\n",
    "            name=\"Player\",\n",
    "            min_width=260,\n",
    "        ),\n",
    "        Column(id=\"athlete_id\", show=False),\n",
    "        Column(id=\"team\", show=False),\n",
    "        Column(id=\"team_name\", show=False),\n",
    "        Column(id=\"gp\", name=\"GP\"),\n",
    "        Column(id=\"ppg\", name=\"PPG\"),\n",
    "    ],\n",
    "    default_page_size=12,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "18",
   "metadata": {},
   "source": [
    "## 9. Highlights: men's college basketball's best and worst units\n",
    "\n",
    "`reactable_sdv_highlight` bolds a column's maximum (green), minimum (red) or both, optionally on a highlighter. Among\n",
    "the top 20 men's college basketball teams of 2025-26 by adjusted efficiency margin it marks the best and worst\n",
    "adjusted offense; for defense, where lower is better, a `(min, max)` pair swaps the colors."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "19",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = mbb.load_mbb_team_boxscore(seasons=[SEASON]).select(\"team_id\", \"team_location\").unique(\"team_id\")\n",
    "mbb_ratings = mbb.load_mbb_ratings(SEASON).with_columns(pl.col(\"team_id\").cast(pl.Int32))  # ids ship as text here\n",
    "assert names.schema[\"team_id\"] == mbb_ratings.schema[\"team_id\"]\n",
    "top20 = (\n",
    "    mbb_ratings.sort(\"rank\")\n",
    "    .head(20)\n",
    "    .join(names, on=\"team_id\", how=\"left\")\n",
    "    .with_columns(pl.col(\"adj_em\", \"adj_o\", \"adj_d\").round(1), logo=pl.col(\"team_id\"))\n",
    "    .select(\"rank\", \"logo\", \"team_location\", \"adj_em\", \"adj_o\", \"adj_d\")\n",
    ")\n",
    "Reactable(\n",
    "    top20,\n",
    "    columns=[\n",
    "        Column(id=\"rank\", name=\"#\", width=50),\n",
    "        reactable_sdv_logos(league=\"mbb\", id=\"logo\", name=\"\", id_system=\"espn\", height=24, width=60),\n",
    "        Column(id=\"team_location\", name=\"Team\", min_width=150),\n",
    "        Column(id=\"adj_em\", name=\"Adj. margin\"),\n",
    "        reactable_sdv_highlight(\n",
    "            top20, which=\"min_max\", highlighter=(\"#fde0dd\", \"#e5f5e0\"), id=\"adj_o\", name=\"Adj. offense\"\n",
    "        ),\n",
    "        reactable_sdv_highlight(\n",
    "            top20,\n",
    "            which=\"min_max\",\n",
    "            font_color=(\"green\", \"red\"),\n",
    "            highlighter=(\"#e5f5e0\", \"#fde0dd\"),\n",
    "            id=\"adj_d\",\n",
    "            name=\"Adj. defense\",\n",
    "        ),\n",
    "    ],\n",
    "    default_page_size=20,\n",
    "    compact=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "20",
   "metadata": {},
   "source": [
    "## 10. Bubble grid: NHL goals for and against, in team colors\n",
    "\n",
    "`reactable_sdv_bubble_grid` draws each value as a circle (or a square, `shape=\"squares\"`) whose width is its share of\n",
    "the column's largest, up to 100 pixels, colored on a ramp or, with `team_col`, in the team's color. The Atlantic\n",
    "Division's goals for (primary colors) and against (secondary colors, as squares) make a grid to scan for the big and\n",
    "small numbers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "21",
   "metadata": {},
   "outputs": [],
   "source": [
    "atlantic = (\n",
    "    nhl.nhl_standings(\"2026-04-16\")\n",
    "    .filter(pl.col(\"division_name\") == \"Atlantic\")\n",
    "    .sort(\"division_sequence\")\n",
    "    .select(team=\"team_abbrev_default\", gf=\"goal_for\", ga=\"goal_against\")\n",
    ")\n",
    "Reactable(\n",
    "    atlantic,\n",
    "    columns=[\n",
    "        reactable_sdv_logos(league=\"nhl\", id=\"team\", name=\"\", include_name=True, height=24, min_width=100),\n",
    "        reactable_sdv_bubble_grid(atlantic, team_col=\"team\", league=\"nhl\", id=\"gf\", name=\"Goals for\", min_width=120),\n",
    "        reactable_sdv_bubble_grid(\n",
    "            atlantic,\n",
    "            team_col=\"team\",\n",
    "            league=\"nhl\",\n",
    "            which=\"secondary\",\n",
    "            shape=\"squares\",\n",
    "            id=\"ga\",\n",
    "            name=\"Goals against\",\n",
    "            min_width=120,\n",
    "        ),\n",
    "    ],\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "sdvplot": {
   "description": "reactablefmtr's cell formatters with sdvplot, one recipe each: NBA data bars with logos, NFL EPA color tiles, MLB color scales, WNBA pill buttons and headshots, NHL icon sets and bubbles, SEC win dots, NFL win trends and men's college basketball highlights.",
   "label": "reactable formatters",
   "position": 13
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
