Skip to content

Commit

Permalink
Replace is.na with rlang::is_na in map_color() (#2131)
Browse files Browse the repository at this point in the history
  • Loading branch information
mojaveazure authored May 4, 2022
1 parent a4ed547 commit 5583518
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions R/plotly_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]] })
Expand Down Expand Up @@ -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]])
Expand All @@ -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"]])
Expand Down

0 comments on commit 5583518

Please sign in to comment.