Skip to content

Commit

Permalink
added error for dimvalues, exported get_scale_defaults (#819 (comment))
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Aug 22, 2024
1 parent ce30024 commit 397dbcd
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ S3method(tmapSubsetShp,sf)
S3method(tmapSubsetShp,sfc)
S3method(tmapSubsetShp,stars)
export(get_fact_levels_na)
export(get_scale_defaults)
export(make_by_vars)
export(marker_icon)
export(opt_tm_bubbles)
Expand Down
4 changes: 4 additions & 0 deletions R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ message_pos_auto = function(type) {
NULL
}

error_dimvalues = function() {
stop("tm_vars(): \"dimvalues\" has been used, but the shape object does not contain any dimensions; please use \"x\" to specify variables", call. = FALSE)
}

3 changes: 3 additions & 0 deletions R/step1_helper_facets.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ step1_rearrange_facets = function(tmo, o) {
#value = value_orig
#names(value) = sapply(value, "[", 1)
} else if (inherits(value, "tmapVars")) {
if (!is.null(value$dimvalues) && length(smeta$dims) == 0L) {
error_dimvalues()
}
if (!is.na(value$x[1])) {
if (is.character(value$x)) {
if (!all(value$x %in% shpvars)) stop("not all variables specified in tm_vars are found", call. = FALSE)
Expand Down
12 changes: 12 additions & 0 deletions R/tmapScale_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ check_values = function(layer, aes, values) {
}
}

#' Internal tmap function get scale values
#'
#' Internal tmap function get scale values
#'
#' @param scale scale
#' @param o o
#' @param aes aes
#' @param layer layer
#' @param cls cls
#' @param ct ct
#' @export
#' @keywords internal
get_scale_defaults = function(scale, o, aes, layer, cls, ct = NULL) {
within(scale, {
values = if (is.na(values[1])) {
Expand Down
25 changes: 25 additions & 0 deletions man/get_scale_defaults.Rd

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

0 comments on commit 397dbcd

Please sign in to comment.