@@ -276,7 +276,14 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
276276 checkmate :: assert_multi_class(pre_output , c(" shiny.tag" , " shiny.tag.list" , " html" ), null.ok = TRUE )
277277 checkmate :: assert_multi_class(post_output , c(" shiny.tag" , " shiny.tag.list" , " html" ), null.ok = TRUE )
278278
279- checkmate :: assert_list(decorators , " teal_transform_module" , null.ok = TRUE )
279+ if (checkmate :: test_list(decorators , " teal_transform_module" , null.ok = TRUE )) {
280+ decorators <- if (checkmate :: test_names(names(decorators ), subset.of = c(" default" , " plot" ))) {
281+ lapply(decorators , list )
282+ } else {
283+ list (default = decorators )
284+ }
285+ }
286+ assert_decorators(decorators , null.ok = TRUE , names = c(" default" , " plot" ))
280287 # End of assertions
281288
282289 # Make UI args
@@ -350,7 +357,7 @@ ui_g_bivariate <- function(id, ...) {
350357 justified = TRUE
351358 )
352359 ),
353- ui_transform_teal_data (ns(" decorate " ), transformators = args $ decorators ),
360+ ui_decorate_teal_data (ns(" decorator " ), decorators = subset_decorators( " plot " , args $ decorators ) ),
354361 if (! is.null(args $ row_facet ) || ! is.null(args $ col_facet )) {
355362 tags $ div(
356363 class = " data-extract-box" ,
@@ -665,47 +672,46 @@ srv_g_bivariate <- function(id,
665672 teal.code :: eval_code(merged $ anl_q_r(), substitute(expr = plot <- cl , env = list (cl = cl )))
666673 })
667674
668- decorated_output_q <- srv_transform_teal_data(" decorate" , data = output_q , transformators = decorators )
669-
670- decorated_output_q_facets <- reactive({
671- ANL <- merged $ anl_q_r()[[" ANL" ]]
672- row_facet_name <- as.vector(merged $ anl_input_r()$ columns_source $ row_facet )
673- col_facet_name <- as.vector(merged $ anl_input_r()$ columns_source $ col_facet )
674-
675- # Add labels to facets
676- nulled_row_facet_name <- varname_w_label(row_facet_name , ANL )
677- nulled_col_facet_name <- varname_w_label(col_facet_name , ANL )
678- facetting <- (isTRUE(input $ facetting ) && (! is.null(row_facet_name ) || ! is.null(col_facet_name )))
679- without_facet <- (is.null(nulled_row_facet_name ) && is.null(nulled_col_facet_name )) || ! facetting
680-
681- print_call <- if (without_facet ) {
682- quote(print(plot ))
683- } else {
684- substitute(
685- expr = {
686- # Add facetting labels
687- # optional: grid.newpage() # nolint: commented_code.
688- # Prefixed with teal.modules.general as its usage will appear in "Show R code"
689- plot <- teal.modules.general :: add_facet_labels(
690- plot ,
691- xfacet_label = nulled_col_facet_name ,
692- yfacet_label = nulled_row_facet_name
693- )
694- grid :: grid.newpage()
695- grid :: grid.draw(plot )
696- },
697- env = list (nulled_col_facet_name = nulled_col_facet_name , nulled_row_facet_name = nulled_row_facet_name )
698- )
699- }
700- decorated_output_q() %> %
701- teal.code :: eval_code(print_call )
702- })
703-
675+ decorated_output_q_facets <- srv_decorate_teal_data(
676+ " decorator" ,
677+ data = output_q ,
678+ decorators = subset_decorators(" plot" , decorators ),
679+ expr = reactive({
680+ ANL <- merged $ anl_q_r()[[" ANL" ]]
681+ row_facet_name <- as.vector(merged $ anl_input_r()$ columns_source $ row_facet )
682+ col_facet_name <- as.vector(merged $ anl_input_r()$ columns_source $ col_facet )
683+
684+ # Add labels to facets
685+ nulled_row_facet_name <- varname_w_label(row_facet_name , ANL )
686+ nulled_col_facet_name <- varname_w_label(col_facet_name , ANL )
687+ facetting <- (isTRUE(input $ facetting ) && (! is.null(row_facet_name ) || ! is.null(col_facet_name )))
688+ without_facet <- (is.null(nulled_row_facet_name ) && is.null(nulled_col_facet_name )) || ! facetting
689+
690+ print_call <- if (without_facet ) {
691+ quote(print(plot ))
692+ } else {
693+ substitute(
694+ expr = {
695+ # Add facetting labels
696+ # optional: grid.newpage() # nolint: commented_code.
697+ # Prefixed with teal.modules.general as its usage will appear in "Show R code"
698+ plot <- teal.modules.general :: add_facet_labels(
699+ plot ,
700+ xfacet_label = nulled_col_facet_name ,
701+ yfacet_label = nulled_row_facet_name
702+ )
703+ grid :: grid.newpage()
704+ grid :: grid.draw(plot )
705+ },
706+ env = list (nulled_col_facet_name = nulled_col_facet_name , nulled_row_facet_name = nulled_row_facet_name )
707+ )
708+ }
709+ print_call
710+ }),
711+ expr_is_reactive = TRUE
712+ )
704713
705- plot_r <- reactive({
706- req(output_q())
707- decorated_output_q_facets()[[" plot" ]]
708- })
714+ plot_r <- reactive(req(decorated_output_q_facets())[[" plot" ]])
709715
710716 pws <- teal.widgets :: plot_with_settings_srv(
711717 id = " myplot" ,
0 commit comments