Skip to content

Commit a4b0e65

Browse files
committed
Use new complete_theme() function to get the complete set of theme elements
1 parent ed106db commit a4b0e65

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

R/ggplotly.R

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,19 @@ gg2list <- function(p, width = NULL, height = NULL,
463463
assign(var, built_env[[var]], envir = envir)
464464
}
465465

466-
# initiate plotly.js layout with some plot-wide theming stuff
467-
theme <- ggfun("plot_theme")(plot)
468-
elements <- names(which(sapply(theme, inherits, "element")))
466+
# Get the "complete" set of theme elements and calculate their values
467+
if (is.function(asNamespace("ggplot2")$complete_theme)) {
468+
theme <- ggplot2::complete_theme(plot$theme)
469+
elements <- names(theme)
470+
} else {
471+
theme <- ggfun("plot_theme")(plot)
472+
elements <- names(which(sapply(theme, inherits, "element")))
473+
}
474+
469475
for (i in elements) {
470476
theme[[i]] <- ggplot2::calc_element(i, theme)
471477
}
478+
472479
# Translate plot wide theme elements to plotly.js layout
473480
pm <- unitConvert(theme$plot.margin, "pixels")
474481
gglayout <- list(

0 commit comments

Comments
 (0)