From 144401d52bed948265fe912e50959d8ab1384571 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 27 Mar 2026 19:49:38 +0100 Subject: [PATCH] Drop the lazyeval dependency in favour of rlang. --- DESCRIPTION | 1 - NAMESPACE | 5 ----- NEWS.md | 2 +- R/ggplotly.R | 6 +++--- R/imports.R | 1 - R/plotly_build.R | 3 ++- R/utils.R | 2 +- 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7a79b8c68f..3cbf41b62d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -41,7 +41,6 @@ Imports: dplyr, vctrs, tibble, - lazyeval (>= 0.2.0), rlang (>= 1.0.0), crosstalk, purrr, diff --git a/NAMESPACE b/NAMESPACE index e8ebe444e5..a799edaa2d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -261,11 +261,6 @@ importFrom(httr,write_disk) importFrom(jsonlite,parse_json) importFrom(jsonlite,read_json) importFrom(jsonlite,toJSON) -importFrom(lazyeval,all_dots) -importFrom(lazyeval,f_eval) -importFrom(lazyeval,f_new) -importFrom(lazyeval,is_formula) -importFrom(lazyeval,is_lang) importFrom(magrittr,"%>%") importFrom(purrr,transpose) importFrom(rlang,"!!!") diff --git a/NEWS.md b/NEWS.md index deae87ce4d..4324cfddb6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # plotly (development version) - +* Removed the dependency on the `{lazyeval}` package. # plotly 4.12.0 diff --git a/R/ggplotly.R b/R/ggplotly.R index a37804dd9e..1c4461fc15 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -1161,13 +1161,13 @@ gg2list <- function(p, width = NULL, height = NULL, mappingFormulas <- lapply(layers, function(x) { mappings <- getAesMap(plot, x) if (originalData) { - lapply(mappings, lazyeval::f_new) + lapply(mappings, function(x) rlang::new_formula(lhs = NULL, rhs = x)) } else { nms <- names(mappings) - setNames(lapply(nms, function(x) lazyeval::f_new(as.name(x))), nms) + setNames(lapply(nms, function(x) rlang::new_formula(lhs = NULL, rhs = as.name(x))), nms) } }) - + return_dat <- if (originalData) layer_data else data # translate group aesthetics to data attributes diff --git a/R/imports.R b/R/imports.R index 548d4e4c70..fa7aaa2cd3 100644 --- a/R/imports.R +++ b/R/imports.R @@ -8,7 +8,6 @@ #' @importFrom jsonlite toJSON parse_json read_json #' @importFrom httr RETRY content config add_headers authenticate stop_for_status warn_for_status write_disk #' @importFrom htmlwidgets createWidget sizingPolicy saveWidget onRender prependContent -#' @importFrom lazyeval f_eval is_formula all_dots is_lang f_new #' @importFrom tibble as_tibble #' @importFrom htmltools browsable tagList tags div #' @importFrom purrr transpose diff --git a/R/plotly_build.R b/R/plotly_build.R index 3bdd432601..daf3c86845 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -1010,7 +1010,8 @@ traceify <- function(dat, x = NULL) { eval_attr <- function(x, data = NULL) { - if (lazyeval::is_formula(x)) lazyeval::f_eval(x, data) else x + if (rlang::is_formula(x)) rlang::eval_tidy(rlang::f_rhs(x), data = data, + env = rlang::f_env(x)) else x } # overwrite defaults with the user defined palette diff --git a/R/utils.R b/R/utils.R index b558e12b03..b94a9a2ef6 100644 --- a/R/utils.R +++ b/R/utils.R @@ -837,7 +837,7 @@ verify_key_type <- function(p) { p$x$data[[i]]$`_isSimpleKey` <- TRUE p$x$data[[i]]$`_isNestedKey` <- FALSE } - p$x$data[[i]]$`_isNestedKey` <- p$x$data[[i]]$`_isNestedKey` %||% !lazyeval::is_atomic(k) + p$x$data[[i]]$`_isNestedKey` <- p$x$data[[i]]$`_isNestedKey` %||% !rlang::is_atomic(k) # key values should always be strings if (p$x$data[[i]]$`_isNestedKey`) { p$x$data[[i]]$key <- lapply(p$x$data[[i]]$key, function(x) I(as.character(x)))