Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sg_button

Buttons


Description

Add buttons to your graph.

Usage

sg_button(
  sg,
  event,
  ...,
  position = "top",
  class = "btn btn-default",
  tag = htmltools::tags$button,
  id = NULL
)

Arguments

sg

An object of class sigmajsas intatiated by sigmajs.

event

Event the button triggers, see valid events.

...

Content of the button, complient with htmltools.

position

Position of button, top or bottom.

class

Button CSS class, see note.

tag

A Valid htmltools tags function.

id

A valid CSS id.

Details

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

Value

An object of class htmlwidget which renders the visualisation on print.

Events

  • force_start

  • force_stop

  • noverlap

  • drag_nodes

  • relative_size

  • add_nodes

  • add_edges

  • drop_nodes

  • drop_edges

  • animate

  • export_svg

  • export_img

  • progress

  • read_exec

Note

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

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(c("force_start", "force_stop"), "start layout")
  
# 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_force_start() %>% 
  sg_force_stop(3000) %>% 
  sg_button(c("force_start", "force_stop"), "start layout") %>% 
  sg_button("add_nodes", "add nodes")

sigmajs

Interface to 'Sigma.js' Graph Visualization Library

v0.1.5
MIT + file LICENSE
Authors
John Coene [aut, cre, cph] (<https://orcid.org/0000-0002-6637-4107>)
Initial release
2020-06-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.