Skip to content

Commit cf7eaff

Browse files
committed
tooltip is a better argument name than mapping
1 parent 71be0cd commit cf7eaff

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
3.3.1 -- 10 Mar 2015
22

3+
CHANGES:
4+
5+
* Changed the mapping argument name to tooltip (which seems like a better name).
6+
37
BUGFIX:
48

59
* Redundant legend entries are no longer shown.

R/ggplotly.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#' @param p a ggplot object.
77
#' @param width Width of the plot in pixels (optional, defaults to automatic sizing).
88
#' @param height Height of the plot in pixels (optional, defaults to automatic sizing).
9-
#' @param mapping a character vector specifying which aesthetic mappings to show
10-
#' in the tooltip. The default, "all", means show all the aesthetic mappings
9+
#' @param tooltip a character vector specifying which aesthetic tooltips to show
10+
#' in the tooltip. The default, "all", means show all the aesthetic tooltips
1111
#' (including the unofficial "text" aesthetic). The order of variables here will
1212
#' also control the order they appear. For example, use
13-
#' \code{mapping = c("y", "x", "colour")} if you want y first, x second, and
13+
#' \code{tooltip = c("y", "x", "colour")} if you want y first, x second, and
1414
#' colour last.
1515
#' @param source Only relevant for \link{event_data}.
1616
#' @seealso \link{signup}, \link{plot_ly}
@@ -31,22 +31,22 @@
3131
#' }
3232
#'
3333
ggplotly <- function(p = ggplot2::last_plot(), width = NULL, height = NULL,
34-
mapping = "all", source = "A") {
35-
l <- gg2list(p, width = width, height = height, mapping = mapping, source = source)
34+
tooltip = "all", source = "A") {
35+
l <- gg2list(p, width = width, height = height, tooltip = tooltip, source = source)
3636
hash_plot(p$data, l)
3737
}
3838

3939
#' Convert a ggplot to a list.
4040
#' @param p ggplot2 plot.
4141
#' @param width Width of the plot in pixels (optional, defaults to automatic sizing).
4242
#' @param height Height of the plot in pixels (optional, defaults to automatic sizing).
43-
#' @param mapping a character vector specifying which aesthetic mappings to show in the
44-
#' tooltip. The default, "all", means show all the aesthetic mappings
43+
#' @param tooltip a character vector specifying which aesthetic tooltips to show in the
44+
#' tooltip. The default, "all", means show all the aesthetic tooltips
4545
#' (including the unofficial "text" aesthetic).
4646
#' @param source Only relevant for \link{event_data}.
4747
#' @return a 'built' plotly object (list with names "data" and "layout").
4848
#' @export
49-
gg2list <- function(p, width = NULL, height = NULL, mapping = "all", source = "A") {
49+
gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A") {
5050
# ------------------------------------------------------------------------
5151
# Our internal version of ggplot2::ggplot_build(). Modified from
5252
# https://github.com/hadley/ggplot2/blob/0cd0ba/R/plot-build.r#L18-L92
@@ -190,8 +190,8 @@ gg2list <- function(p, width = NULL, height = NULL, mapping = "all", source = "A
190190
# remove leading/trailing dots in "hidden" stat aes
191191
map <- sub("^\\.\\.", "", sub("\\.\\.$", "", map))
192192
# TODO: allow users to specify a _list_ of mappings?
193-
if (!identical(mapping, "all")) {
194-
map <- map[names(map) %in% mapping]
193+
if (!identical(tooltip, "all")) {
194+
map <- map[names(map) %in% tooltip]
195195
}
196196
# tooltips for discrete positional scales are misleading
197197
if (scales$get_scales("x")$is_discrete()) {

man/gg2list.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ggplotly.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)