handle_click: Handle mouse actions on marks.

View source: R/handle_click.R

handle_clickR 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))

ggvis documentation built on May 29, 2024, 1:12 a.m.