@@ -463,18 +463,7 @@ gg2list <- function(p, width = NULL, height = NULL,
463
463
assign(var , built_env [[var ]], envir = envir )
464
464
}
465
465
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
-
475
- for (i in elements ) {
476
- theme [[i ]] <- ggplot2 :: calc_element(i , theme )
477
- }
466
+ theme <- calculated_theme_elements(plot )
478
467
479
468
# Translate plot wide theme elements to plotly.js layout
480
469
pm <- unitConvert(theme $ plot.margin , " pixels" )
@@ -1161,6 +1150,23 @@ gg2list <- function(p, width = NULL, height = NULL,
1161
1150
# Due to the non-standard use of assign() in g2list() (above)
1162
1151
utils :: globalVariables(c(" groupDomains" , " layers" , " prestats_data" , " scales" , " sets" ))
1163
1152
1153
+ # Get the "complete" set of theme elements and their calculated values
1154
+ calculated_theme_elements <- function (plot ) {
1155
+ if (is.function(asNamespace(" ggplot2" )$ complete_theme )) {
1156
+ theme <- ggplot2 :: complete_theme(plot $ theme )
1157
+ elements <- names(theme )
1158
+ } else {
1159
+ theme <- ggfun(" plot_theme" )(plot )
1160
+ elements <- names(which(sapply(theme , inherits , " element" )))
1161
+ }
1162
+
1163
+ for (i in elements ) {
1164
+ theme [[i ]] <- ggplot2 :: calc_element(i , theme )
1165
+ }
1166
+
1167
+ theme
1168
+ }
1169
+
1164
1170
1165
1171
# -----------------------------------------------------------------------------
1166
1172
# ggplotly 'utility' functions
0 commit comments