interplay: Interplay

Description Usage Arguments Examples

View source: R/interplay.R

Description

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

Usage

1
2
3
4
5

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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"
      )
    )
  )

devOpifex/g2r documentation built on Jan. 16, 2022, 12:36 a.m.