-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathvisStabilize.R
105 lines (88 loc) · 3.62 KB
/
visStabilize.R
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#' Network visualization stabilize method
#'
#' For use stabilize() method in a shiny app. For full documentation, have a look at \link{visDocumentation}.
#'
#'@param graph : a \code{\link{visNetworkProxy}} object
#'@param iterations : Optional. If wanted, the number of iterations
#'
#'@seealso \link{visNodes} for nodes options, \link{visEdges} for edges options, \link{visGroups} for groups options,
#'\link{visLegend} for adding legend, \link{visOptions} for custom option, \link{visLayout} & \link{visHierarchicalLayout} for layout,
#'\link{visPhysics} for control physics, \link{visInteraction} for interaction, \link{visNetworkProxy} & \link{visFocus} & \link{visFit} for animation within shiny,
#'\link{visDocumentation}, \link{visEvents}, \link{visConfigure} ...
#'
#' @examples
#'\dontrun{
#'
#'# have a look to :
#'shiny::runApp(system.file("shiny", package = "visNetwork"))
#'
#'}
#'
#'@export
#'@references See online documentation \url{https://datastorm-open.github.io/visNetwork/}
visStabilize <- function(graph, iterations = NULL){
if(!any(class(graph) %in% "visNetwork_Proxy")){
stop("Can't use visFit with visNetwork object. Only within shiny & using visNetworkProxy")
}
options <- list()
options$iterations <- iterations
data <- list(id = graph$id, options = options)
graph$session$sendCustomMessage("visShinyStabilize", data)
graph
}
#' Network visualization startSimulation method
#'
#' For use startSimulation() method in a shiny app. For full documentation, have a look at \link{visDocumentation}.
#'
#'@param graph : a \code{\link{visNetworkProxy}} object
#'
#'@seealso \link{visNodes} for nodes options, \link{visEdges} for edges options, \link{visGroups} for groups options,
#'\link{visLegend} for adding legend, \link{visOptions} for custom option, \link{visLayout} & \link{visHierarchicalLayout} for layout,
#'\link{visPhysics} for control physics, \link{visInteraction} for interaction, \link{visNetworkProxy} & \link{visFocus} & \link{visFit} for animation within shiny,
#'\link{visDocumentation}, \link{visEvents}, \link{visConfigure} ...
#'
#' @examples
#'\dontrun{
#'
#'# have a look to :
#'shiny::runApp(system.file("shiny", package = "visNetwork"))
#'
#'}
#'
#'@export
visStartSimulation <- function(graph){
if(!any(class(graph) %in% "visNetwork_Proxy")){
stop("Can't use visFit with visNetwork object. Only within shiny & using visNetworkProxy")
}
data <- list(id = graph$id)
graph$session$sendCustomMessage("StartSimulation", data)
graph
}
#' Network visualization stopSimulation method
#'
#' For use stopSimulation() method in a shiny app. For full documentation, have a look at \link{visDocumentation}.
#'
#'@param graph : a \code{\link{visNetworkProxy}} object
#'
#'@seealso \link{visNodes} for nodes options, \link{visEdges} for edges options, \link{visGroups} for groups options,
#'\link{visLegend} for adding legend, \link{visOptions} for custom option, \link{visLayout} & \link{visHierarchicalLayout} for layout,
#'\link{visPhysics} for control physics, \link{visInteraction} for interaction, \link{visNetworkProxy} & \link{visFocus} & \link{visFit} for animation within shiny,
#'\link{visDocumentation}, \link{visEvents}, \link{visConfigure} ...
#'
#' @examples
#'\dontrun{
#'
#'# have a look to :
#'shiny::runApp(system.file("shiny", package = "visNetwork"))
#'
#'}
#'
#'@export
visStopSimulation <- function(graph){
if(!any(class(graph) %in% "visNetwork_Proxy")){
stop("Can't use visFit with visNetwork object. Only within shiny & using visNetworkProxy")
}
data <- list(id = graph$id)
graph$session$sendCustomMessage("StopSimulation", data)
graph
}