Description Usage Arguments Examples
Configure global interplay (interactions) for the chart.
See gauge_interplay()
to customise figure-level interplay.
1 2 3 4 5 | interplay(g, ...)
remove_interplay(g, ...)
register_interplay(g, name, ...)
|
g |
An object of class |
... |
String(s) defining interactions. |
name |
Name of interaction to register |
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"
)
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.