Skip to content

Commit

Permalink
Protect list of variables
Browse files Browse the repository at this point in the history
If this is not done (or similar), in rare situations the `recurse` function splits the variable list into parts if it happens to match length of the column to split by.

Fixes plotly#2419
  • Loading branch information
romanzenka committed Feb 21, 2025
1 parent aa619dc commit cbe30cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

* Closed #2337: Creating a new `event_data()` handler no longer causes a spurious reactive update of existing `event_data()`s. (#2339)
* Closed #2376: Removes errant boxmode warning for grouped boxplot. (#2396)
* Closed #2419: Issue with NA handling in scatter plots: Two NAs per category cause incorrect line connection (#2419)

# 4.10.4

Expand Down
2 changes: 2 additions & 0 deletions R/plotly_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,12 @@ traceify <- function(dat, x = NULL) {
recurse <- function(z, n, idx) {
if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) z[idx] else z
}
varMapping <- dat[[".plotlyVariableMapping"]] # Protect this value from recurse
new_dat <- list()
for (j in seq_along(lvls)) {
new_dat[[j]] <- lapply(dat, function(y) recurse(y, n, x %in% lvls[j]))
new_dat[[j]]$name <- new_dat[[j]]$name %||% lvls[j]
new_dat[[j]]$.plotlyVariableMapping <- varMapping
}
return(new_dat)
}
Expand Down

0 comments on commit cbe30cc

Please sign in to comment.