R/interact.R

Defines functions interact_drag interact_zoom interact_slider interact_brush

Documented in interact_brush interact_drag interact_slider interact_zoom

#' Brush
#' 
#' Add brush interactions.
#' 
#' @inheritParams geoms
#' 
#' @examples
#' range <- range(cars$speed)
#' 
#' g2(cars, asp(speed, dist)) %>% 
#'   fig_point() %>% 
#'   interact_brush()
#' 
#' @name interact
#' @export
interact_brush <- function(g2) {
  check_g2(g2)
  g2$x$brush <- TRUE
  g2
}

#' @rdname interact
#' @export
interact_slider <- function(g2, ...) {
  check_g2(g2)
  g2$x$slider <- list(...)
  g2
}

#' @rdname interact
#' @export
interact_zoom <- function(g2, ...) {
  check_g2(g2)
  g2$x$zoom <- list(...)
  g2
}

#' @rdname interact
#' @export
interact_drag <- function(g2, ...) {
  check_g2(g2)
  g2$x$drag <- list(...)
  g2
}
JohnCoene/g2r documentation built on March 6, 2021, 8:11 p.m.