Skip to content

Commit

Permalink
add key_none()
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Sep 11, 2024
1 parent 4eb0d2e commit 3b42b98
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export(key_log)
export(key_manual)
export(key_map)
export(key_minor)
export(key_none)
export(key_range_auto)
export(key_range_manual)
export(key_range_map)
Expand Down
3 changes: 3 additions & 0 deletions R/aaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ standard_extract_key <- function(scale, aesthetic, key, ...) {
if (is.function(key)) {
key <- key(scale, aesthetic)
}
if (is_empty(key)) {
return(key)
}
if ("aesthetic" %in% names(key)) {
key$aesthetic <-
scale_transform(key$aesthetic, scale, map = TRUE, "aesthetic")
Expand Down
13 changes: 13 additions & 0 deletions R/key-.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#' break positions for minor tick marks.
#' * `key_log()` is a function factory whose functions place ticks at intervals
#' in log10 space.
#' * `key_none()` makes an empty key with no entries.
#'
#' @param aesthetic,value A vector of values for the guide to represent
#' equivalent to the `breaks` argument in scales. The `aesthetic` will be
Expand Down Expand Up @@ -75,6 +76,9 @@
#'
#' # Values from a `<data.frame>`
#' key_map(ToothGrowth, aesthetic = unique(supp))
#'
#' # Empty key
#' key_none()
NULL

#' @rdname key_standard
Expand Down Expand Up @@ -171,6 +175,15 @@ key_log <- function(
}
}

#' @rdname key_standard
#' @export
key_none <- function() {
new_data_frame(
list(aesthetic = logical(), .value = logical(), .label = character()),
n = 0L, class = c("key_standard", "key_guide")
)
}

# Helpers -----------------------------------------------------------------

validate_key_types <- function(key, call = caller_env()) {
Expand Down
7 changes: 7 additions & 0 deletions man/key_standard.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3b42b98

Please sign in to comment.