1
#' Events
2
#' 
3
#' Get events server-side.
4
#' 
5
#' @inheritParams sg_nodes
6
#' @param events A vector of valid events (see section below).
7
#' 
8
#' @details Events:
9
#' Valid events to pass to \code{events}.
10
#' \itemize{
11
#'   \item{\code{clickNode}}
12
#'   \item{\code{clickNodes}}
13
#'   \item{\code{clickEdge}}
14
#'   \item{\code{clickEdges}}
15
#'   \item{\code{clickStage}}
16
#'   \item{\code{doubleClickStage}}
17
#'   \item{\code{rightClickStage}}
18
#'   \item{\code{doubleClickNode}}
19
#'   \item{\code{doubleClickNodes}}  
20
#'   \item{\code{doubleClickEdge}}
21
#'   \item{\code{doubleClickEdges}}
22
#'   \item{\code{rightClickNode}}
23
#'   \item{\code{rightClickNodes}}
24
#'   \item{\code{rightClickEdge}}
25
#'   \item{\code{rightClickEdges}}
26
#'   \item{\code{hoverNode}}
27
#'   \item{\code{hoverNodes}}
28
#'   \item{\code{hoverEdge}}
29
#'   \item{\code{hoverEdges}}
30
#'   \item{\code{outNode}}
31
#'   \item{\code{outNodes}}
32
#'   \item{\code{outEdge}}
33
#'   \item{\code{outEdges}}
34
#' }
35
#' 
36
#' @examples 
37
#' library(shiny)
38
#' 
39
#' nodes <- sg_make_nodes()
40
#' edges <- sg_make_edges(nodes)
41
#' 
42
#' ui <- fluidPage(
43
#'   sigmajsOutput("sg"),
44
#'   p("Click on a node"),
45
#'   verbatimTextOutput("clicked")
46
#' ) 
47
#' 
48
#' server <- function(input, output){
49
#'   output$sg <- renderSigmajs({
50
#'     sigmajs() %>%
51
#'       sg_nodes(nodes, id, size, color) %>%
52
#'       sg_edges(edges, id, source, target) %>% 
53
#'       sg_events("clickNode")
54
#'   })
55
#' 
56
#' # capture node clicked
57
#' output$clicked <- renderPrint({
58
#'     input$sg_click_node
59
#'   })
60
#' }
61
#' 
62
#' \dontrun{shinyApp(ui, server)}
63
#' 
64
#' @seealso \href{https://github.com/jacomyal/sigma.js/wiki/Events-API}{official documentation}.
65
#' 
66
#' @return An object of class \code{htmlwidget} which renders the visualisation on print.
67
#' 
68
#' @export 
69
sg_events <- function(sg, events){
70 0
  if(missing(events))
71 0
    stop("Must specify events, see events section in man page.")
72

73 0
  sg$x$events <- append(sg$x$events, as.list(events))
74 0
  return(sg)
75
}

Read our documentation on viewing source code .

Loading