Skip to content

Commit

Permalink
read delay resets force
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCoene committed Mar 8, 2019
1 parent 8fb5fa7 commit aaf910c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
15 changes: 8 additions & 7 deletions R/graph_proxies.R
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,9 @@ sg_read_exec_p <- function(proxy){
#' @param proxy An object of class \code{sigmajsProxy} as returned by \code{\link{sigmajsProxy}}.
#' @param data A \code{data.frame} of _one_ node or edge.
#' @param ... any column.
#' @param batch Column name of containing batch identifier.
#' @param delay Column name of containing batch identifier.
#' @param refresh Whether to refresh the graph after each batch (\code{delay}) has been added to the graph.
#' Note that this will also automatically restart any running force layout.
#'
#' @examples
#' library(shiny)
Expand All @@ -629,11 +630,11 @@ sg_read_exec_p <- function(proxy){
#' id = 1:80,
#' source = c(
#' sample(1:25, 40, replace = TRUE),
#' sample(26:50, 40, replace = TRUE)
#' sample(1:50, 40, replace = TRUE)
#' ),
#' target = c(
#' sample(1:25, 40, replace = TRUE),
#' sample(26:50, 40, replace = TRUE)
#' sample(1:50, 40, replace = TRUE)
#' ),
#' batch = c(
#' rep(1000, 40),
Expand All @@ -643,10 +644,10 @@ sg_read_exec_p <- function(proxy){
#' dplyr::mutate_all(as.character)
#'
#' sigmajsProxy("sg") %>%
#' sg_read_batch_nodes_p(nodes, id, color, label, size, batch = "batch") %>%
#' sg_read_batch_edges_p(edges, id, source, target, batch = "batch") %>%
#' sg_read_batch_exec_p() %>%
#' sg_refresh_p()
#' sg_force_start_p() %>%
#' sg_read_delay_nodes_p(nodes, id, color, label, size, delay = "batch") %>%
#' sg_read_delay_edges_p(edges, id, source, target, delay = "batch") %>%
#' sg_read_delay_exec_p()
#' })
#'
#' }
Expand Down
7 changes: 7 additions & 0 deletions inst/htmlwidgets/sigmajs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,10 +1043,17 @@ if (HTMLWidgets.shinyMode) {
var s = get_sigma_graph(message.id);
if (typeof s != 'undefined') {
message.data.forEach(function(data){
var running = s.isForceAtlas2Running();
setTimeout(function () {
if (message.refresh === true && running === true) {
s.killForceAtlas2();
}
s.graph.read(data);
if(message.refresh === true)
s.refresh();
if (message.refresh === true && running === true) {
s.startForceAtlas2();
}
}, data.nodes[0].delay);
});
}
Expand Down
17 changes: 9 additions & 8 deletions man/read-batch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aaf910c

Please sign in to comment.