Skip to content

Commit

Permalink
noverlap fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCoene committed Jul 3, 2018
1 parent cbacd6f commit f5c67d3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
12 changes: 5 additions & 7 deletions R/noverlap.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
#'
#' @param proxy An object of class \code{sigmajsProxy} as returned by \code{\link{sigmajsProxy}}.
#' @param sg An object of class \code{sigmajs}as intatiated by \code{\link{sigmajs}}.
#' @param start Whether to start running the noverlap layout.
#' @param ... any option to pass to the plugin, see \href{https://github.com/jacomyal/sigma.js/tree/master/plugins/sigma.layout.noverlap}{official documentation}.
#'
#' @examples
#' nodes <- sg_make_nodes(50)
#' edges <- sg_make_edges(nodes, 75)
#' nodes <- sg_make_nodes(500)
#' edges <- sg_make_edges(nodes)
#'
#' sigmajs() %>%
#' sg_nodes(nodes, id, label, size, color) %>%
#' sg_nodes(nodes, id, size, color) %>%
#' sg_edges(edges, id, source, target) %>%
#' sg_force() %>%
#' sg_layout() %>%
#' sg_noverlap()
#'
#' @rdname noverlap
#' @export
sg_noverlap <- function(sg, start = TRUE, ...) {
sg_noverlap <- function(sg, ...) {

if (missing(sg))
stop("missing sg", call. = FALSE)
Expand All @@ -28,7 +27,6 @@ sg_noverlap <- function(sg, start = TRUE, ...) {
stop("sg must be of class sigmajs", call. = FALSE)

sg$x$noverlap <- list(...)
sg$x$noverlapStart <- start
sg
}

Expand Down
7 changes: 3 additions & 4 deletions inst/htmlwidgets/sigmajs.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,14 @@ HTMLWidgets.widget({
// start noverlap
if (x.hasOwnProperty('noverlap')) {
var noverlap = s.configNoverlap(x.noverlap);
if (x.noverlapStart === true) {
s.startNoverlap();
}

if(x.button.event === 'noverlap'){
button.addEventListener("click", function(event) {
s.startNoverlap();
});
}
} else {
s.startNoverlap();
}
}

// custom shapes
Expand Down
12 changes: 5 additions & 7 deletions man/noverlap.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_that("test init", {

expect_length(sg$x$settings, 1)
expect_true(sg$x$neighbours)
expect_true(sg$x$noverlapStart)
expect_length(sg$x$noverlap, 0)
expect_equal(sg$x$relativeSize, 1)

expect_error(sg_export_img())
Expand Down

0 comments on commit f5c67d3

Please sign in to comment.