Add buttons to your graph.

sg_button(sg, label, event, class = "btn btn-default")

Arguments

sg

An object of class sigmajsas intatiated by sigmajs.

label

Button label.

event

Event the button triggers, see valid events.

class

Button CSS class, see note.

Details

You can pass multiple events as a vector, see examples.

Note

The default class (btn btn-default) works with Bootstrap 3 (the default framework for Shiny and R markdown).

Events

  • force_start

  • force_stop

  • noverlap

  • drag_nodes

  • relative_size

  • add_nodes

  • add_edges

  • drop_nodes

  • drop_edges

  • animate

  • export_svg

  • export_img

Examples

nodes <- sg_make_nodes() edges <- sg_make_edges(nodes) # Button starts the layout and stops it after 3 seconds sigmajs() %>% sg_nodes(nodes, id, size) %>% sg_edges(edges, id, source, target) %>% sg_force_start() %>% sg_force_stop(3000) %>% sg_button("start layout", c("force_start", "force_stop")) # additional nodes nodes2 <- sg_make_nodes() nodes2$id <- as.character(seq(11, 20)) # add delay nodes2$delay <- runif(nrow(nodes2), 500, 1000) sigmajs() %>% sg_nodes(nodes, id, label, size, color) %>% sg_add_nodes(nodes2, delay, id, label, size, color) %>% sg_button("add nodes", "add_nodes")