Skip to content

Commit cbe30cc

Browse files
committed
Protect list of variables
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
1 parent aa619dc commit cbe30cc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

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

1617
# 4.10.4
1718

R/plotly_build.R

+2
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,12 @@ traceify <- function(dat, x = NULL) {
995995
recurse <- function(z, n, idx) {
996996
if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) z[idx] else z
997997
}
998+
varMapping <- dat[[".plotlyVariableMapping"]] # Protect this value from recurse
998999
new_dat <- list()
9991000
for (j in seq_along(lvls)) {
10001001
new_dat[[j]] <- lapply(dat, function(y) recurse(y, n, x %in% lvls[j]))
10011002
new_dat[[j]]$name <- new_dat[[j]]$name %||% lvls[j]
1003+
new_dat[[j]]$.plotlyVariableMapping <- varMapping
10021004
}
10031005
return(new_dat)
10041006
}

0 commit comments

Comments
 (0)