Learn R Programming

ggvis (version 0.4.1)

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: [object Object],[object Object],[object Object]
on_mouse_out
Callback function with argument: [object Object]

Examples

Run this code
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 DataLab