From 697398380eaf899ec33001fb801d1276e34cfcfc Mon Sep 17 00:00:00 2001 From: jwildfire Date: Tue, 20 Apr 2021 13:09:27 -0400 Subject: [PATCH 1/2] add support for export flag in chart config. fix-520 --- R/makeChartConfig.R | 6 ++++++ R/mod_reportsTab.R | 5 ++--- inst/report/safetyGraphicsReport.Rmd | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/makeChartConfig.R b/R/makeChartConfig.R index 644c369e..c1dd1fc6 100644 --- a/R/makeChartConfig.R +++ b/R/makeChartConfig.R @@ -73,6 +73,12 @@ makeChartConfig <- function(dirs, sourceFiles=TRUE){ chart$order ) %>% as.numeric + chart$export <- ifelse( + is.null(chart$export), + true, + chart$export + ) + return(chart) }) diff --git a/R/mod_reportsTab.R b/R/mod_reportsTab.R index 3b2176e1..93cc1ae1 100644 --- a/R/mod_reportsTab.R +++ b/R/mod_reportsTab.R @@ -47,10 +47,9 @@ reportsTab <- function(input, output, session, charts, data, mapping){ # create checkbox for selecting charts of interest output$checkboxes <- renderUI({ # no support for modules or broken widgets yet - noExport <- c("aeTimelines","hepexplorer","safetyShiftPlot","tplyr_shift") chart_type <- charts %>% map(., ~.$type) %>% unlist - chart_name <- charts %>% map(., ~.$name) %>% unlist - charts_keep <- ((! chart_type == "module") & (! chart_name %in% noExport)) + chart_export <- charts %>% map(., ~.$export) %>% unlist + charts_keep <- ((! chart_type == "module") & (chart_export)) charts_labels <- charts %>% map(., ~ .$label) %>% unlist charts_vec <- names(charts)[charts_keep] diff --git a/inst/report/safetyGraphicsReport.Rmd b/inst/report/safetyGraphicsReport.Rmd index 466ee5ed..1f8ca666 100644 --- a/inst/report/safetyGraphicsReport.Rmd +++ b/inst/report/safetyGraphicsReport.Rmd @@ -48,7 +48,6 @@ create_chart <- function(chart, params){ null = "null", ) } - widgetParams$ns <-chart$name #Still not working quite right. May need to refactor widgets a bit to, since some use this parameter to select the location of the wrapper div. there's no easy way to set this to the random widget value (e.g. "htmlwidget-638ca0176b34007fbdf9") return(widgetParams) } From ba247589b447ab45ef14a340852bcaaabac5fd61 Mon Sep 17 00:00:00 2001 From: jwildfire Date: Wed, 21 Apr 2021 13:24:44 -0400 Subject: [PATCH 2/2] drop chart when order is negative. fix #524 --- R/makeChartConfig.R | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/R/makeChartConfig.R b/R/makeChartConfig.R index c1dd1fc6..6ac2ea62 100644 --- a/R/makeChartConfig.R +++ b/R/makeChartConfig.R @@ -73,19 +73,28 @@ makeChartConfig <- function(dirs, sourceFiles=TRUE){ chart$order ) %>% as.numeric + #charts should be available to export unless the are modules or chart$export is set to false chart$export <- ifelse( is.null(chart$export), - true, + TRUE, chart$export ) return(chart) }) - + names(charts) <- yaml_files %>% file_path_sans_ext %>% basename - charts <- charts[order(purrr::map_dbl(charts, function(chart) chart$order))] + charts <- charts[order(purrr::map_dbl(charts, function(chart) chart$order))] + + # Drop charts where order is negative + drops <- charts[purrr::map_lgl(charts, function(chart) chart$order < 0)] + if(length(drops)>0){ + message("Dropped ", length(drops), " charts: ",paste(names(drops),collapse=", ")) + message("To display these charts, set the `order` parameter in the chart object or yaml file to a positive number.") + charts <- charts[purrr::map_lgl(charts, function(chart) chart$order >= 0)] + } - message("Found ", length(yaml_files), " config files: ",paste(names(charts),collapse=", ")) + message("Loaded ", length(charts), " charts: ",paste(names(charts),collapse=", ")) # Bind workflow functions to chart object all_functions <- as.character(utils::lsf.str(".GlobalEnv"))