ggvis (version 0.4.3)

handle_click: 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

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataCamp Workspace