-
Notifications
You must be signed in to change notification settings - Fork 12
/
setInteractivity.R
28 lines (27 loc) · 1.07 KB
/
setInteractivity.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#' Get and set interactivity mode
#'
#' \code{setInteractivity} globally sets the interactivity mode of plot
#' functions. This is useful to avoid repeating \code{interactive = FALSE} or
#' \code{interactive = TRUE} in each function. \code{getInteractivity} gets the
#' interactivity mode.
#'
#' @param interactive Should plot functions generate a UI that lets users to
#' interactively modify input data and graphical parameters of a chart? It should
#' be TRUE or FALSE. The default behavior is to set it to TRUE if the R session
#' is interactive and to FALSE otherwise (for instance in Rmarkdown document).
#'
#' @return
#' \code{getInteractivity} returns a boolean indicating the interactivity mode of
#' plot functions. \code{setInteractivity} is only used for its side effects.
#'
#' @export
setInteractivity <- function(interactive = "auto") {
if (interactive == "auto") interactive <- interactive()
options(antaresVizInteractive = interactive)
invisible(TRUE)
}
#' @export
#' @rdname setInteractivity
getInteractivity <- function() {
getOption("antaresVizInteractive")
}