diff --git a/NAMESPACE b/NAMESPACE index eb46d4c658..25291e11f7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,6 +37,7 @@ S3method(print,api_plot) S3method(print,kaleidoScope) S3method(print,plotly_data) S3method(to_basic,GeomAbline) +S3method(to_basic,GeomAlluvium) S3method(to_basic,GeomAnnotationMap) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -48,6 +49,7 @@ S3method(to_basic,GeomDensity2d) S3method(to_basic,GeomDotplot) S3method(to_basic,GeomErrorbar) S3method(to_basic,GeomErrorbarh) +S3method(to_basic,GeomFunction) S3method(to_basic,GeomHex) S3method(to_basic,GeomHline) S3method(to_basic,GeomJitter) @@ -66,6 +68,7 @@ S3method(to_basic,GeomSf) S3method(to_basic,GeomSmooth) S3method(to_basic,GeomSpoke) S3method(to_basic,GeomStep) +S3method(to_basic,GeomStratum) S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) @@ -254,6 +257,7 @@ importFrom(purrr,transpose) importFrom(rlang,"!!!") importFrom(rlang,"!!") importFrom(rlang,eval_tidy) +importFrom(rlang,is_na) importFrom(stats,complete.cases) importFrom(stats,is.leaf) importFrom(stats,quantile) diff --git a/NEWS.md b/NEWS.md index 0d1341fb5a..8401d34223 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,6 +16,7 @@ * `ggplotly()` now respects `guide(aes = "none")` (e.g., `guide(fill = "none")`) when constructing legend entries. (#2067) * Fixed an issue with translating `GGally::ggcorr()` via `ggplotly()`. (#2012) * Fixed an issue where clearing a crosstalk filter would raise an error in the JS console (#2087) +* Fixed an issue where `map_color()` would throw an error on R 4.2 (#2131) ## Improvements diff --git a/R/plotly_build.R b/R/plotly_build.R index 16e9f1ca99..0f0a4e1511 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -673,6 +673,8 @@ map_size <- function(traces, stroke = FALSE) { } # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale +#' @importFrom rlang is_na +# map_color <- function(traces, stroke = FALSE, title = "", colorway, na.color = "transparent") { color <- if (stroke) { lapply(traces, function(x) { x[["stroke"]] %||% x[["color"]] }) @@ -743,7 +745,7 @@ map_color <- function(traces, stroke = FALSE, title = "", colorway, na.color = " if (!has_attr(type, attr)) next if (is_colorway && "textfont" == attr) next col <- if (isSingular) rgba_ else if (array_ok(attrs[[attr]]$color)) rgba else NA - if (is.na(col)) { + if (is_na(col)) { warning("`", attr, ".color` does not currently support multiple values.", call. = FALSE) } else { trace[[attr]] <- modify_list(list(color = default_(col)), trace[[attr]]) @@ -759,7 +761,7 @@ map_color <- function(traces, stroke = FALSE, title = "", colorway, na.color = " } else if (has_attr(type, "line")) { # if fill does not exist, 'color' controls line.color col <- if (isSingular) rgba_ else if (array_ok(attrs$line$color)) rgba else NA - if (is.na(col)) { + if (is_na(col)) { warning("`line.color` does not currently support multiple values.", call. = FALSE) } else { trace[["line"]] <- modify_list(list(color = default_(col)), trace[["line"]])