Skip to contents

Adds individual layer to a myIO widget

Usage

addIoLayer(
  myIO,
  type,
  color = NULL,
  label,
  data = NULL,
  mapping,
  transform = "identity",
  options = list(barSize = "large", toolTipOptions = list(suppressY = FALSE))
)

Arguments

myIO

an htmlwidget object created by the myIO() function

type

chart type

color

optional CSS color string or vector for grouped layers. For type = "regression" the first element colors the raw scatter and the optional second element colors the fitted line and confidence band; supply the same color twice to render data and model in a single hue.

label

unique layer label

data

data frame backing the layer

mapping

named aesthetic mapping list. Field requires x_var, y_var, time (numeric seconds), and entity; team, label, and kind are optional.

transform

transform name applied before serialization

options

layer options passed through to the widget config. For field, pitchLength and pitchWidth default to 105 and 68 meters; maxGap defaults to 0.5 seconds. events is a list of records, or a data.frame with one row per event, with time, type, and player fields. Field analysis overlays are off by default: overlays = list(shape = TRUE, separation = TRUE) enables the team width x depth box and the selected player's nearest-opponent line with a metrics panel. minPlayers (whole number >= 2, default 2) is the fewest positioned players for a team width or depth; below it the metric is missing, never 0. excludeEntities is a vector of entity ids (e.g. goalkeepers) left out of shape metrics only. metricWindow = c(t0, t1) sets the interval, in seconds, for the mean/min/max summaries; the default is the whole clip.

Value

A modified myIO htmlwidget object with the new layer appended to the configuration.

Examples

myIO(data = mtcars) |>
  addIoLayer(
    type = "point", label = "points",
    mapping = list(x_var = "wt", y_var = "mpg")
  )