
Team-Colored Cell Styles for 'reactable' Tables
Source:R/reactable_sdv.R
reactable_sdv_team_color.RdStyle functions for reactable::colDef() that color cells
with a team's primary or secondary color: a horizontal bar whose length
is proportional to the cell value, or a translucent background fill.
Usage
reactable_sdv_team_color_bar(
data,
team_col,
sport = c("nfl", "nba", "wnba", "mlb", "nhl", "cfb", "mbb", "wbb"),
type = c("primary", "secondary"),
max_value = NULL,
na_color = "grey70"
)
reactable_sdv_team_color_bg(
data,
team_col,
sport = c("nfl", "nba", "wnba", "mlb", "nhl", "cfb", "mbb", "wbb"),
type = c("primary", "secondary"),
alpha = 0.15,
na_color = "grey70"
)Arguments
- data
The data frame passed to
reactable::reactable(). Needed to look up the team of each row.- team_col
Character. Name of the column in
dataholding team abbreviations.- sport
Character string identifying the sport. One of
supported_sports().- type
Character.
"primary"or"secondary"team color.- max_value
Numeric. Reference value that fills the whole cell. If
NULL(the default), the maximum of the styled column is used.- na_color
Color used when a team cannot be resolved.
- alpha
Numeric. Opacity of the background fill in
[0, 1].
Value
A function with signature function(value, index, name) suitable
for the style argument of reactable::colDef().