Skip to content

Commit

Permalink
Update nesting.R
Browse files Browse the repository at this point in the history
fix for e_add_nested in cases of more than one dataset in an echart
  • Loading branch information
rdatasculptor authored Oct 21, 2023
1 parent c7863c2 commit 55b8d3d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions R/nesting.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,30 @@ e_add_nested <- function(e, param, ..., .serie = NULL, .data = NULL) {
if (missing(e) || missing(param)) {
stop("missing e or param", call. = FALSE)
}

if(is.null(.data))
ds <- e$x$data
else
ds <- map_grps_(.data, e$x$tl)

for (i in seq_along(ds)) {
data <- ds[[i]] |>
dplyr::select(...)

data <- apply(data, 1, as.list)

for (j in seq_along(data)) {
if(!is.null(.serie) && .serie != j)
next

if (!e$x$tl) {
e$x$opts$series[[i]]$data[[j]][[param]] <- data[[j]]
for(k in seq_along(e$x$opts$series)){
if(!is.null(.serie) && .serie != k)
next
e$x$opts$series[[k]]$data[[j]][[param]] <- data[[j]]
}
} else {
for(k in seq_along(e$x$opts$options[[i]]$series)){
if(!is.null(.serie) && .serie != k)
next
e$x$opts$options[[i]]$series[[k]]$data[[j]][[param]] <- data[[j]]
}
}
Expand Down

0 comments on commit 55b8d3d

Please sign in to comment.