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

198 Include user's card labels when generating the report #336

Merged
merged 12 commits into from
Oct 13, 2023
13 changes: 8 additions & 5 deletions R/barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,14 @@ srv_g_barplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Barplot")
card$append_text("Barplot", "header2")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "Barplot",
label = label,
description = NULL,
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
encodings_list <- list(
"Experiment:",
Expand Down
13 changes: 8 additions & 5 deletions R/boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,14 @@ srv_g_boxplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Boxplot")
card$append_text("Boxplot", "header2")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "Boxplot",
label = label,
description = NULL,
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
encodings_list <- list(
"Experiment:",
Expand Down
13 changes: 8 additions & 5 deletions R/forestplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,14 @@ srv_g_forest_tte <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Forest Plot")
card$append_text("Forest Plot", "header2")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "Forest Plot",
label = label,
description = NULL,
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
encodings_list <- list(
"Experiment:",
Expand Down
13 changes: 8 additions & 5 deletions R/km.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,14 @@ srv_g_km <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Kaplan-Meier Plot")
card$append_text("Kaplan-Meier Plot", "header2")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "Kaplan-Meier Plot",
label = label,
description = NULL,
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
encodings_list <- list(
"Experiment:",
Expand Down
13 changes: 8 additions & 5 deletions R/pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,14 @@ srv_g_pca <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("PCA")
card$append_text("PCA", "header2")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "PCA",
label = label,
description = NULL,
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
if (input$tab_selected == "PCA") {
encodings_list <- list(
Expand Down
14 changes: 8 additions & 6 deletions R/quality.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,14 @@ srv_g_quality <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Quality Control Plot")
card$append_text("Quality Control Plot", "header2")
card$append_text(tools::toTitleCase(input$plot_type), "header3")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "Quality Control Plot",
label = label,
description = tools::toTitleCase(input$plot_type),
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
encodings_list <- list(
"Experiment:",
Expand Down
13 changes: 8 additions & 5 deletions R/scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,14 @@ srv_g_scatterplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Scatter Plot")
card$append_text("Scatter Plot", "header2")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "Scatter Plot",
label = label,
description = NULL,
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
encodings_list <- list(
"Experiment:",
Expand Down
25 changes: 25 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,28 @@ include_js_files <- function(pattern = "*") { # nolint
)
return(singleton(lapply(js_files, includeScript)))
}

#' Template function to generate reporter card for `teal.modules.hermes`
#' @param title (`character(1)`) title of the card (unless overwritten by label)
#' @param label (`character(1)`) label provided by the user when adding the card
#' @param description (`character(1)`) optional additional description
#' @param with_filter (`logical(1)`) flag indicating to add filter state
#' @param filter_panel_api (`FilterPanelAPI`) object with API that allows the generation
#' of the filter state in the report
#'
#' @return (`TealReportCard`) populated with a title, description and filter state
#'
#' @keywords internal
card_template <- function(title, label, description = NULL, with_filter, filter_panel_api) {
card <- teal::TealReportCard$new()
title <- if (label == "") title else label
card$set_name(title)
card$append_text(title, "header2")
if (!is.null(description)) {
card$append_text(description, "header3")
}
if (with_filter) {
card$append_fs(filter_panel_api$get_filter_state())
}
card
}
13 changes: 8 additions & 5 deletions R/volcanoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,14 @@ srv_g_volcanoplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Volcano Plot")
card$append_text("Volcano Plot", "header2")
card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- card_template(
title = "Volcano Plot",
label = label,
description = NULL,
with_filter = TRUE,
filter_panel_api = filter_panel_api
)
card$append_text("Selected Options", "header3")
encodings_list <- list(
"Experiment:",
Expand Down
27 changes: 27 additions & 0 deletions man/card_template.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.