2828# ' @section Decorating `tm_g_association`:
2929# '
3030# ' This module generates the following objects, which can be modified in place using decorators:
31- # ' - `plot_top` (`ggplot2`)
32- # ' - `plot_bottom` (`ggplot2`)
31+ # ' - `plot` (`grob` created with [ggplot2::ggplotGrob()])
3332# '
3433# ' For additional details and examples of decorators, refer to the vignette
3534# ' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
@@ -176,7 +175,16 @@ tm_g_association <- function(label = "Association",
176175 plot_choices <- c(" Bivariate1" , " Bivariate2" )
177176 checkmate :: assert_list(ggplot2_args , types = " ggplot2_args" )
178177 checkmate :: assert_subset(names(ggplot2_args ), c(" default" , plot_choices ))
179- checkmate :: assert_list(decorators , " teal_transform_module" , null.ok = TRUE )
178+
179+ if (checkmate :: test_list(decorators , " teal_transform_module" , null.ok = TRUE )) {
180+ decorators <- if (checkmate :: test_names(names(decorators ), subset.of = c(" default" ))) {
181+ lapply(decorators , list )
182+ } else {
183+ list (default = decorators )
184+ }
185+ }
186+ assert_decorators(decorators , null.ok = TRUE , names = c(" default" ))
187+
180188 # End of assertions
181189
182190 # Make UI args
@@ -247,7 +255,7 @@ ui_tm_g_association <- function(id, ...) {
247255 " Log transformed" ,
248256 value = FALSE
249257 ),
250- ui_transform_teal_data (ns(" decorate " ), transformators = args $ decorators ),
258+ ui_decorate_teal_data (ns(" decorator " ), decorators = subset_decorators( " default " , args $ decorators ) ),
251259 teal.widgets :: panel_group(
252260 teal.widgets :: panel_item(
253261 title = " Plot settings" ,
@@ -405,8 +413,6 @@ srv_tm_g_association <- function(id,
405413 # association
406414 ref_class_cov <- ifelse(association , ref_class , " NULL" )
407415
408- print_call <- quote(print(p ))
409-
410416 var_calls <- lapply(vars_names , function (var_i ) {
411417 var_class <- class(ANL [[var_i ]])[1 ]
412418 if (is.numeric(ANL [[var_i ]]) && log_transformation ) {
@@ -488,6 +494,7 @@ srv_tm_g_association <- function(id,
488494 expr = {
489495 plot_top <- plot_calls [[1 ]]
490496 plot_bottom <- plot_calls [[1 ]]
497+ plot <- tern :: stack_grobs(grobs = lapply(list (plot_top , plot_bottom ), ggplotGrob ))
491498 },
492499 env = list (
493500 plot_calls = do.call(
@@ -500,23 +507,19 @@ srv_tm_g_association <- function(id,
500507 )
501508 })
502509
503- decorated_output_q <- srv_transform_teal_data(" decorate" , data = output_q , transformators = decorators )
504- decorated_output_grob_q <- reactive({
505- within(
506- decorated_output_q(),
507- {
508- plot <- tern :: stack_grobs(grobs = lapply(list (plot_top , plot_bottom ), ggplotGrob ))
509- grid :: grid.newpage()
510- grid :: grid.draw(plot )
511- }
512- )
513- })
514-
510+ decorated_output_grob_q <- srv_decorate_teal_data(
511+ id = " decorator" ,
512+ data = output_q ,
513+ decorators = subset_decorators(" plot" , decorators ),
514+ expr = {
515+ grid :: grid.newpage()
516+ grid :: grid.draw(plot )
517+ }
518+ )
515519
516520 plot_r <- reactive({
517521 req(iv_r()$ is_valid())
518- req(output_q())
519- decorated_output_grob_q()[[" plot" ]]
522+ req(decorated_output_grob_q())[[" plot" ]]
520523 })
521524
522525 pws <- teal.widgets :: plot_with_settings_srv(
0 commit comments