From a8c492a1bcebdd26af33f711aff40c494e646b87 Mon Sep 17 00:00:00 2001 From: Aaron Clark Date: Tue, 28 Jul 2020 12:08:01 -0400 Subject: [PATCH] automatically adjust the size of the watermark depending on if coloring by another variable. effects pdf only --- R/mod_indvExpPatVisits_fct_plot.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/mod_indvExpPatVisits_fct_plot.R b/R/mod_indvExpPatVisits_fct_plot.R index 0d04e0e8..2a622509 100755 --- a/R/mod_indvExpPatVisits_fct_plot.R +++ b/R/mod_indvExpPatVisits_fct_plot.R @@ -109,11 +109,11 @@ fnIndvExplVisits <- function( extra_aval_vars <- c("ATM","ATPT") if(most_avals_per_visit > 1 & any(extra_aval_vars %in% colnames(plot_dat))){ # Grab first available variable that exists and could explain why their are extra avals - avals_by <- sym(extra_aval_vars[extra_aval_vars %in% colnames(plot_dat)][1]) + avals_by <<- sym(extra_aval_vars[extra_aval_vars %in% colnames(plot_dat)][1]) if(avals_by == "ATM") { plot_dat <- plot_dat %>% mutate(ATM = as.POSIXct(paste("1970-01-01",ATM))) } - # if discrete atpt, use color aesthetic + # if discrete atpt, use color aesthetic automatically if(avals_by == "ATPT"){ lb_plot <- lb_plot + suppressWarnings( @@ -149,6 +149,7 @@ fnIndvExplVisits <- function( } } else { # no color by variable in legend or hover text + avals_by <<- "" lb_plot <- lb_plot + suppressWarnings(geom_point(na.rm = TRUE, aes(text = paste0(AVISIT, @@ -175,8 +176,9 @@ fnIndvExplVisits <- function( # Smaller watermark annotate("text", x = Inf, y = -Inf, label = "tidyCDISC: PROOF ONLY", - hjust=1.1, vjust=-3.3, col="white", cex=20, - fontface = "bold", alpha = 0.8) + hjust=1.1, vjust=-3.3, col="white", fontface = "bold", alpha = 0.8, + cex = ifelse(avals_by == "" | rlang::is_empty(avals_by),16,12) + ) }