Neighbor highlighting via mouseover and click at the same time
1 |
#' Custom shapes
|
|
2 |
#'
|
|
3 |
#' Indicate a graph uses custom shapes
|
|
4 |
#'
|
|
5 |
#' @param sg An object of class \code{sigmajs}as intatiated by \code{\link{sigmajs}}.
|
|
6 |
#'
|
|
7 |
#' @export
|
|
8 |
sg_custom_shapes <- function(sg) { |
|
9 |
|
|
10 | 1 |
if (missing(sg)) |
11 | 1 |
stop("missing sg", call. = FALSE) |
12 |
|
|
13 | 1 |
.test_sg(sg) |
14 |
|
|
15 | 1 |
sg$x$customShapes <- TRUE |
16 | 1 |
sg |
17 |
}
|
|
18 |
|
|
19 |
#' Add images to nodes
|
|
20 |
#'
|
|
21 |
#' Add images to nodes with the \href{https://github.com/jacomyal/sigma.js/tree/master/plugins/sigma.renderers.customShapes}{Custom Shapes plugin}.
|
|
22 |
#'
|
|
23 |
#' @param sg An object of class \code{sigmajs}as intatiated by \code{\link{sigmajs}}.
|
|
24 |
#' @param data Data.frame containing columns.
|
|
25 |
#' @param url URL of image.
|
|
26 |
#' @param ... Any other column.
|
|
27 |
#'
|
|
28 |
#' @seealso \href{https://github.com/jacomyal/sigma.js/tree/master/plugins/sigma.renderers.customShapes}{Official documentation}
|
|
29 |
#'
|
|
30 |
#' @examples
|
|
31 |
#' \dontrun{
|
|
32 |
#' demo("custom-shapes", package = "sigmajs")
|
|
33 |
#' }
|
|
34 |
#'
|
|
35 |
#' @export
|
|
36 |
sg_add_images <- function(sg, data, url, ...) { |
|
37 |
|
|
38 | 1 |
if (missing(sg) || missing(url) || missing(data)) |
39 | 1 |
stop("missing sg, url or data", call. = FALSE) |
40 |
|
|
41 | 1 |
.test_sg(sg) |
42 |
|
|
43 | 1 |
if (!length(sg$x$data$nodes)) |
44 | 1 |
stop("missing nodes", call. = FALSE) |
45 |
|
|
46 | 1 |
if (length(sg$x$data$nodes) != nrow(data)) |
47 | 1 |
stop("data must have as many rows as nodes", call. = FALSE) |
48 |
|
|
49 | 1 |
data <- .build_data(data, url, ...) |
50 |
|
|
51 | 1 |
sg <- .add_image(sg, data) |
52 |
|
|
53 | 1 |
sg %>%
|
54 | 1 |
sg_custom_shapes()
|
55 |
}
|
Read our documentation on viewing source code .