% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/visNetworkEvents.R
\name{visEvents}
\alias{visEvents}
\title{Network visualization events}
\usage{
visEvents(
  graph,
  type = "on",
  click = NULL,
  doubleClick = NULL,
  oncontext = NULL,
  hold = NULL,
  release = NULL,
  select = NULL,
  selectNode = NULL,
  selectEdge = NULL,
  deselectNode = NULL,
  deselectEdge = NULL,
  dragStart = NULL,
  dragging = NULL,
  dragEnd = NULL,
  controlNodeDragging = NULL,
  controlNodeDragEnd = NULL,
  hoverNode = NULL,
  blurNode = NULL,
  hoverEdge = NULL,
  blurEdge = NULL,
  zoom = NULL,
  showPopup = NULL,
  hidePopup = NULL,
  startStabilizing = NULL,
  stabilizationProgress = NULL,
  stabilizationIterationsDone = NULL,
  stabilized = NULL,
  resize = NULL,
  initRedraw = NULL,
  beforeDrawing = NULL,
  afterDrawing = NULL,
  animationFinished = NULL,
  configChange = NULL
)
}
\arguments{
\item{graph}{: a visNetwork object}

\item{type}{: Character. "on" (Default) to full listener, "once" to set an event listener only once, or "off" to disable a listener.}

\item{click}{: Fired when the user clicks the mouse or taps on a touchscreen device.}

\item{doubleClick}{: Fired when the user double clicks the mouse or double taps on a touchscreen device. Since a double click is in fact 2 clicks, 2 click events are fired, followed by a double click event. If you do not want to use the click events if a double click event is fired, just check the time between click events before processing them.}

\item{oncontext}{: Fired when the user click on the canvas with the right mouse button. The right mouse button does not select by default. You can use the method getNodeAt to select the node if you want.}

\item{hold}{: Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. A click event is also fired in this case.}

\item{release}{: Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.}

\item{select}{: Fired when the selection has changed by user action. This means a node or edge has been selected, added to the selection or deselected. All select events are only triggered on click and hold.}

\item{selectNode}{: Fired when a node has been selected by the user.}

\item{selectEdge}{: Fired when a edge has been selected by the user.}

\item{deselectNode}{: Fired when a node (or nodes) has (or have) been deselected by the user. The previous selection is the list of nodes and edges that were selected before the last user event.}

\item{deselectEdge}{: Fired when a edge (or edges) has (or have) been deselected by the user. The previous selection is the list of nodes and edges that were selected before the last user event.}

\item{dragStart}{: Fired when starting a drag.}

\item{dragging}{: Fired when dragging node(s) or the view.}

\item{dragEnd}{: Fired when the drag has finished.}

\item{controlNodeDragging}{: Fired when dragging control node. Control Edge is edge that is being dragged and contains ids of 'from' and 'to' nodes. If control node is not dragged over another node, 'to' field is undefined. See \link{visDocumentation}.}

\item{controlNodeDragEnd}{: Fired when the control node drag has finished. See \link{visDocumentation}.}

\item{hoverNode}{: Fired interaction:{hover:true} and the mouse hovers over a node.}

\item{blurNode}{: Fired interaction:{hover:true} and the mouse moved away from a node it was hovering over before.}

\item{hoverEdge}{: Fired interaction:{hover:true} and the mouse hovers over a edge}

\item{blurEdge}{: Fired interaction:{hover:true} and the mouse moved away from a edge it was hovering over before.}

\item{zoom}{: Fired when the user zooms in or out. The properties tell you which direction the zoom is in. The scale is a number greater than 0, which is the same that you get with network.getScale().}

\item{showPopup}{: Fired when the popup (tooltip) is shown.}

\item{hidePopup}{: Fired when the popup (tooltip) is hidden.}

\item{startStabilizing}{: Fired when stabilization starts. This is also the case when you drag a node and the physics simulation restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.}

\item{stabilizationProgress}{: Fired when a multiple of the updateInterval number of iterations is reached. This only occurs in the 'hidden' stabilization. Passes an object with properties structured as:}

\item{stabilizationIterationsDone}{: Fired when the 'hidden' stabilization finishes. This does not necessarily mean the network is stabilized; it could also mean that the amount of iterations defined in the options has been reached.}

\item{stabilized}{: Fired when the network has stabilized or when the stopSimulation() has been called. The amount of iterations it took could be used to tweak the maximum amount of iterations needed to stabilize the network.}

\item{resize}{: Fired when the size of the canvas has been resized, either by a redraw call when the container div has changed in size, a setSize() call with new values or a setOptions() with new width and/or height values.}

\item{initRedraw}{: Fired before the redrawing begins. The simulation step has completed at this point. Can be used to move custom elements before starting drawing the new frame.}

\item{beforeDrawing}{: Fired after the canvas has been cleared, scaled and translated to the viewing position but before all edges and nodes are drawn. Can be used to draw behind the network.}

\item{afterDrawing}{: Fired after drawing on the canvas has been completed. Can be used to draw on top of the network.}

\item{animationFinished}{: Fired when an animation is finished.}

\item{configChange}{: Fired when a user changes any option in the configurator. The options object can be used with the setOptions method or stringified using JSON.stringify(). You do not have to manually put the options into the network: this is done automatically. You can use the event to store user options in the database.}
}
\description{
Network visualization events. For full documentation, have a look at \link{visDocumentation}.
Use \code{type = "once"} to set an event listener only once, and \code{type = "off"} to disable all the related events.
}
\examples{

nodes <- data.frame(id = 1:3)
edges <- data.frame(from = c(1,2), to = c(1,3))

visNetwork(nodes, edges) \%>\%
 visEvents(select = "function(properties) {
     alert('selected nodes: ' + properties.nodes);}", 
     dragEnd = "function(properties) {
     alert('finish to drag');}")

# set one 
visNetwork(nodes, edges) \%>\%
 visEvents(type = "once", select = "function() {
     alert('first selection');}") \%>\%
 visEvents(select = "function(properties) {
     alert('selected nodes: ' + properties.nodes);}", 
     dragEnd = "function(properties) {
     alert('finish to drag');}")
      
# use this to get the network
visNetwork(nodes, edges) \%>\%
  visEvents(type = "once", startStabilizing = "function() {
            this.moveTo({scale:0.1})}") \%>\%
  visPhysics(stabilization = FALSE)

# shift+click, .....
visNetwork(nodes, edges) \%>\%
    visEvents(click = "function(e) {
            if(e.event.srcEvent.shiftKey){
              alert('shift+click event')
            } else if(e.event.srcEvent.ctrlKey){
              alert('ctrl+click event')
            }else if(e.event.srcEvent.altKey){
              alert('alt+click event')
            } else {
              alert('click event')
            }
          }")
          
}
\references{
See online documentation \url{http://datastorm-open.github.io/visNetwork/}
}
\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} ...
}
