Skip to content

Commit ebb6352

Browse files
committed
fix: implement automatic zorder assignment for proper trace layering
This commit fixes the box plot layering issue where box plots always rendered behind other traces (ribbons, lines) despite correct layer ordering in ggplot2. Implements automatic zorder assignment based on ggplot2 layer order using new plotly.js functionality
1 parent a18da2c commit ebb6352

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

R/ggplotly.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,14 @@ gg2list <- function(p, width = NULL, height = NULL,
11531153
l$cur_data <- ids[[layerData]]
11541154
l$visdat <- setNames(lapply(return_dat, function(x) function(y) x), ids)
11551155

1156+
# automatically assign zorder values based on trace positionAdd commentMore actions
1157+
# this ensures proper layering (later traces on top) for ggplot2 without manual intervention
1158+
for (i in seq_along(l$data)) {
1159+
if (is.null(l$data[[i]]$zorder)) {
1160+
l$data[[i]]$zorder <- i
1161+
}
1162+
}
1163+
11561164
l
11571165
}
11581166

0 commit comments

Comments
 (0)