Configure global interplay (interactions) for the chart. See gauge_interplay() to customise figure-level interplay.

interplay(g, ...)

remove_interplay(g, ...)

register_interplay(g, name, ...)

Arguments

g

An object of class g2r or g2Proxy as returned by g2() or g2_proxy().

...

String(s) defining interactions.

name

Name of interaction to register

Examples

# global interaction on chart
df <- data.frame(
  x = letters,
  y = runif(26)
)

g2(df, asp(x, y)) %>%
  fig_interval(
    selected(fill = "orange")
  ) %>%
  interplay("element", "selected")

# brush
g2(cars, asp(speed, dist)) %>%
  fig_point(asp(interplay = "brush"))

# register
df <- data.frame(
  x = c(letters, letters),
  y = runif(52),
  grp = c(rep("a", 26), rep("b", 26))
)

g2(df, asp(x, y, color = grp)) %>%
  fig_interval(
    asp(interplay = "element-highlight-by-color"),
    adjust("dodge")
  ) %>%
  register_interplay(
    "element-highlight-by-color",
    start = list(
      list(
        trigger = "element:mouseenter",
        action = "element-highlight-by-color:highlight"
      )
    ),
    end = list(
      list(
        trigger = "element:mouseleave",
        action = "element-highlight-by-color:reset"
      )
    )
  )