R: Handle mouse actions on marks.

handle_click {ggvis} | R Documentation

## Handle mouse actions on marks.

### Description

Handle mouse actions on marks.

### Usage

    handle_click(vis, on_click = NULL)

    handle_hover(vis, on_mouse_over = NULL, on_mouse_out = NULL)

### Arguments

`vis` | Visualisation to listen to.
`on_click, on_mouse_over` | Callback function with arguments: data A data frame with one row location A named list with components x and y session The session, used to communicate with the browser
`on_mouse_out` | Callback function with argument: session The session, used to communicate with the browser

### Examples

    location <- function(location, ...) cat(location$x, "x", location$y, "\n")
    mtcars %>% ggvis(~mpg, ~wt) %>% layer_points() %>%
      handle_click(location)
    mtcars %>% ggvis(~mpg, ~wt) %>% layer_points() %>%
      handle_hover(function(...) cat("over\n"), function(...) cat("off\n"))
    mtcars %>% ggvis(~mpg, ~wt) %>% layer_points() %>%
      handle_hover(function(data, ...) str(data))

[Package ggvis version 0.4.3 Index]