Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

301 delayed variable_choices for facet_var in tm_g_gh_boxplot #313

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions R/tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ tm_g_gh_boxplot <- function(label,
dataname = dataname,
param_var = param_var,
trt_group = trt_group,
facet_var = facet_var,
color_manual = color_manual,
shape_manual = shape_manual,
plot_height = plot_height,
Expand Down Expand Up @@ -256,13 +255,6 @@ ui_g_boxplot <- function(id, ...) {
multiple = FALSE
),
uiOutput(ns("axis_selections")),
teal.widgets::optionalSelectInput(
ns("facet_var"),
label = "Facet by",
choices = get_choices(a$facet_var$choices),
selected = a$facet_var$selected,
multiple = FALSE
),
templ_ui_constraint(ns, label = "Data Constraint"), # required by constr_anl_q
if (length(a$hline_vars) > 0) {
teal.widgets::optionalSelectInput(
Expand Down Expand Up @@ -312,7 +304,6 @@ srv_g_boxplot <- function(id,
dataname,
param_var,
trt_group,
facet_var,
color_manual,
shape_manual,
plot_height,
Expand All @@ -331,6 +322,8 @@ srv_g_boxplot <- function(id,
resolved_x <- teal.transform::resolve_delayed(module_args$xaxis_var, env)
resolved_y <- teal.transform::resolve_delayed(module_args$yaxis_var, env)
resolved_param <- teal.transform::resolve_delayed(module_args$param, env)
resolved_facet_var <- teal.transform::resolve_delayed(module_args$facet_var, env)

templ_ui_params_vars(
session$ns,
xparam_choices = resolved_param$choices,
Expand All @@ -339,7 +332,9 @@ srv_g_boxplot <- function(id,
xchoices = resolved_x$choices,
xselected = resolved_x$selected,
ychoices = resolved_y$choices,
yselected = resolved_y$selected
yselected = resolved_y$selected,
facet_choices = resolved_facet_var$choices,
facet_selected = resolved_facet_var$selected
)
})
# reused in all modules
Expand Down Expand Up @@ -477,6 +472,7 @@ srv_g_boxplot <- function(id,
xaxis_var <- input$yaxis_var # nolint
font_size <- input$font_size
trt_group <- input$trt_group
facet_var <- input$facet_var

anl_q()$qenv %>% teal.code::eval_code(
code = bquote({
Expand All @@ -486,7 +482,7 @@ srv_g_boxplot <- function(id,
param_var = .(param_var),
param = .(param),
xaxis_var = .(xaxis_var),
facet_var = .(input$facet_var)
facet_var = .(facet_var)
)
})
)
Expand Down
13 changes: 13 additions & 0 deletions R/utils-templ_ui.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ templ_ui_params_vars <- function(ns,
ychoices = NULL,
yselected = NULL,
yvar_label = NULL, # variable, e.g. AVAL
# facet_var
facet_choices = NULL,
facet_selected = NULL,

multiple = FALSE) {
if (is.null(xparam_choices) && !is.null(xchoices) && !is.null(yparam_choices)) {
# otherwise, xchoices will appear first without any biomarker to select and this looks odd in the UI
Expand Down Expand Up @@ -69,6 +73,15 @@ templ_ui_params_vars <- function(ns,
ychoices, yselected,
multiple = multiple
)
},
if (!is.null(facet_choices)) {
teal.widgets::optionalSelectInput(
ns("facet_var"),
label = "Facet by",
choices = facet_choices,
selected = facet_selected,
multiple = FALSE
)
}
)
}
Loading