Skip to content

Commit acb9c60

Browse files
committed
avoid hiding legend entries of merged traces
1 parent 260df21 commit acb9c60

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

R/ggplotly.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ gg2list <- function(p, width = NULL, height = NULL, mapping = "all", source = "A
585585
hashes <- vapply(traces, function(x) digest::digest(x[names(x) %in% props]), character(1))
586586
modes <- vapply(traces, function(x) x$mode %||% "", character(1))
587587
nhashes <- length(unique(hashes))
588+
browser()
588589
if (nhashes < length(traces)) {
589590
mergedTraces <- vector("list", nhashes)
590591
for (i in unique(hashes)) {
@@ -593,6 +594,9 @@ gg2list <- function(p, width = NULL, height = NULL, mapping = "all", source = "A
593594
if (all(modes[idx] %in% c("lines", "markers"))) {
594595
mergedTraces[[i]] <- Reduce(modifyList, traces[idx])
595596
mergedTraces[[i]]$mode <- "markers+lines"
597+
if (any(sapply(traces[idx], "[[", "showlegend"))) {
598+
mergedTraces[[i]]$showlegend <- TRUE
599+
}
596600
}
597601
}
598602
traces <- mergedTraces

0 commit comments

Comments
 (0)