1
#' Settings
2
#' 
3
#' Graph settings.
4
#' 
5
#' @inheritParams sg_nodes
6
#' @param proxy A proxy as returned by \code{\link{sigmajsProxy}}.
7
#' @param ... Any parameter, see \href{https://github.com/jacomyal/sigma.js/wiki/Settings}{official documentation}.
8
#' 
9
#' @examples 
10
#' nodes <- sg_make_nodes()
11
#'
12
#' edges <- sg_make_edges(nodes, 50)
13
#'
14
#' sigmajs() %>%
15
#'   sg_nodes(nodes, id, label, size) %>%
16
#'   sg_edges(edges, id, source, target) %>% 
17
#'   sg_force() %>% 
18
#'   sg_settings(
19
#'     defaultNodeColor = "#0011ff"
20
#'   )
21
#' 
22
#' @rdname sg_settings
23
#' @export
24
sg_settings <- function(sg, ...) {
25

26 1
	if (missing(sg))
27 1
		stop("missing sg", call. = FALSE)
28

29 1
	if (!inherits(sg, "sigmajs"))
30 1
		stop("sg must be of class sigmajs", call. = FALSE)
31

32 1
  sg$x$settings <- list(...)
33 1
  sg
34
}
35

36
#' @rdname sg_settings
37
#' @export
38
sg_settings_p <- function(proxy, ...){
39 0
	message <- list(id = proxy$id, opts = list(...))
40 0
	proxy$session$sendCustomMessage("sg_settings_p", message)
41 0
	return(proxy)
42
}
43
#' Refresh instance
44
#'
45
#' Refresh your instance.
46
#' 
47
#' @param proxy An object of class \code{sigmajsProxy} as returned by \code{\link{sigmajsProxy}}.
48
#'
49
#' @details It is often required to refresh the instance when using proxies.
50
#'
51
#' @export
52
sg_refresh_p <- function(proxy) {
53

54 0
	if (!"sigmajsProxy" %in% class(proxy))
55 0
		stop("must pass sigmajsProxy object", call. = FALSE)
56

57 0
	message <- list(id = proxy$id)
58

59 0
	proxy$session$sendCustomMessage("sg_refresh_p", message)
60

61 0
	return(proxy)
62
}

Read our documentation on viewing source code .

Loading