animation_p: Animate

Description Usage Arguments Details Value Note See Also Examples

Description

Proxy to dynamically animate an already existing graph.

Usage

1
2
3
4
5
6
sg_animate_p(
  proxy,
  mapping,
  options = list(easing = "cubicInOut"),
  delay = 5000
)

Arguments

proxy

An object of class sigmajsProxy as returned by sigmajsProxy.

mapping

Variables to map animation to.

options

Animations options.

delay

Delay in milliseconds before animation is triggered.

Details

You can animate, x, y, size and color.

Value

The proxy object.

Note

You have to make sure that all the columns you want to animate to (e.g. to_x, to_size) are also provided as arguments when you create the graph with sigmajs() %>% sg_nodes().

See Also

sg_animate

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
## Not run: 
# generate graph
nodes <- sg_make_nodes(20)
edges <- sg_make_edges(nodes)

# add transition
n <- nrow(nodes)
nodes$to_x <- runif(n, 5, 10)
nodes$to_y <- runif(n, 5, 10)
nodes$to_size <- runif(n, 5, 10)

# in server function:
output$my_sigmajs_id <- renderSigmajs({
  sigmajs() %>%
    sg_nodes(nodes, id, label, size, color, to_x, to_y, to_size) %>%
    sg_edges(edges, id, source, target)
})

observeEvent(input$button, {
  sigmajsProxy("my_sigmajs_id") %>%
    sg_animate_p(mapping = list(x = "to_x", y = "to_y", size = "to_size"),
                 options = list(duration = 1000), delay = 0)
})

## End(Not run)

JohnCoene/sigmajs documentation built on Feb. 1, 2021, 12:12 p.m.