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 #241

Merged
merged 26 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fd9baaa
add card_template function and allow to pass label to reporter card c…
kartikeyakirar Oct 4, 2023
e5e941b
Merge fd9baaa4095657173006a03a1f72a9c25e2e93f0 into 6fb64c3996cd9ec8a…
kartikeyakirar Oct 4, 2023
aae8874
[skip actions] Restyle files
github-actions[bot] Oct 4, 2023
b71ed51
adding option selection section in card_template.
kartikeyakirar Oct 5, 2023
402ffc8
Merge branch '198_card_labels@main' of https://github.com/insightseng…
kartikeyakirar Oct 5, 2023
1a26427
fixing indentation.
kartikeyakirar Oct 5, 2023
7301664
Merge 1a2642790f3b83ba6515d6ff85b350cce516d554 into 6fb64c3996cd9ec8a…
kartikeyakirar Oct 5, 2023
9e19c70
[skip actions] Restyle files
github-actions[bot] Oct 5, 2023
e079528
'Empty-Commit'
kartikeyakirar Oct 5, 2023
2118b41
wrapper function for teal.reporter card_template
kartikeyakirar Oct 11, 2023
2a4c5a7
renaming to report_card_template
kartikeyakirar Oct 12, 2023
5dc9092
Merge 2a4c5a7a9cb709e2288461e002478cc4c9c62de8 into 6fb64c3996cd9ec8a…
kartikeyakirar Oct 12, 2023
fe35a27
[skip actions] Restyle files
github-actions[bot] Oct 12, 2023
e7f44be
renaming to report_card_template_goshawk
kartikeyakirar Oct 12, 2023
5d51479
empty commit
kartikeyakirar Oct 12, 2023
4077203
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Oct 12, 2023
d5fc23b
'Empty-Commit'
kartikeyakirar Oct 12, 2023
90fa05d
replacing Rd file
kartikeyakirar Oct 12, 2023
e8ad09a
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Oct 12, 2023
1daee0c
Adding description and changing case.
kartikeyakirar Oct 12, 2023
5481ed8
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Oct 12, 2023
11108d4
'Empty-Commit'
kartikeyakirar Oct 12, 2023
28a101a
updating rd
kartikeyakirar Oct 12, 2023
aecdef4
[skip actions] Roxygen Man Pages Auto Update
dependabot-preview[bot] Oct 12, 2023
97042ba
'Empty-Commit'
kartikeyakirar Oct 12, 2023
b10f687
fixing linter issue.
kartikeyakirar Oct 13, 2023
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
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL
object_usage_linter = NULL,
indentation_linter = NULL
)
30 changes: 17 additions & 13 deletions R/tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -548,20 +548,24 @@ srv_g_boxplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Box Plot")
card$append_text("Box Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card$append_text("Selected Options", "header3")
card$append_text(
paste(
formatted_data_constraint(input$constraint_var, input$constraint_range_min, input$constraint_range_max),
"\nFacet By:",
if (length(input$facet_var) != 0) input$facet_var else "None",
"\nSelect an X-axis Variable:",
input$xaxis_var
card_fun <- function(comment, label) {
constraint_description <- paste(
"\nFacet By:",
if (length(input$facet_var) != 0) input$facet_var else "None",
"\nSelect an X-axis Variable:",
input$xaxis_var
)
card <- report_card_template_goshawk(
title = "Box Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api,
constraint_list = list(
constraint_var = input$constraint_var,
constraint_range_min = input$constraint_range_min,
constraint_range_max = input$constraint_range_max
),
constraint_description = constraint_description,
style = "verbatim"
)
card$append_text("Plot", "header3")
Expand Down
30 changes: 17 additions & 13 deletions R/tm_g_gh_correlationplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -875,20 +875,24 @@ srv_g_correlationplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Correlation Plot")
card$append_text("Correlation Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card$append_text("Selected Options", "header3")
card$append_text(
paste(
formatted_data_constraint(input$constraint_var, input$constraint_range_min, input$constraint_range_max),
"\nTreatment Variable Faceting:",
input$trt_facet,
"\nRegression Line:",
input$reg_line
card_fun <- function(comment, label) {
constraint_description <- paste(
"\nTreatment Variable Faceting:",
input$trt_facet,
"\nRegression Line:",
input$reg_line
)
card <- report_card_template_goshawk(
title = "Correlation Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api,
constraint_list = list(
constraint_var = input$constraint_var,
constraint_range_min = input$constraint_range_min,
constraint_range_max = input$constraint_range_max
),
constraint_description = constraint_description,
style = "verbatim"
)
card$append_text("Plot", "header3")
Expand Down
19 changes: 11 additions & 8 deletions R/tm_g_gh_density_distribution_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,17 @@ srv_g_density_distribution_plot <- function(id, # nolint

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Density Distribution Plot")
card$append_text("Density Distribution Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card$append_text("Selected Options", "header3")
card$append_text(
formatted_data_constraint(input$constraint_var, input$constraint_range_min, input$constraint_range_max)
card_fun <- function(comment, label) {
card <- report_card_template_goshawk(
title = "Density Distribution Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api,
constraint_list = list(
constraint_var = input$constraint_var,
constraint_range_min = input$constraint_range_min,
constraint_range_max = input$constraint_range_max
)
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = plot_data$dim())
Expand Down
30 changes: 17 additions & 13 deletions R/tm_g_gh_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -793,20 +793,24 @@ srv_lineplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Line Plot")
card$append_text("Line Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card$append_text("Selected Options", "header3")
card$append_text(
paste(
formatted_data_constraint(input$constraint_var, input$constraint_range_min, input$constraint_range_max),
"\nSelect Line Splitting Variable:",
if (!is.null(input$shape)) input$shape else "None",
"\nContributing Observations Threshold:",
input$count_threshold
card_fun <- function(comment, label) {
constraint_description <- paste(
"\nSelect Line Splitting Variable:",
if (!is.null(input$shape)) input$shape else "None",
"\nContributing Observations Threshold:",
input$count_threshold
)
card <- report_card_template_goshawk(
title = "Line Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api,
constraint_list = list(
constraint_var = input$constraint_var,
constraint_range_min = input$constraint_range_min,
constraint_range_max = input$constraint_range_max
),
constraint_description = constraint_description,
style = "verbatim"
)
card$append_text("Plot", "header3")
Expand Down
30 changes: 17 additions & 13 deletions R/tm_g_gh_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,24 @@ 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")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card$append_text("Selected Options", "header3")
card$append_text(
paste(
formatted_data_constraint(input$constraint_var, input$constraint_range_min, input$constraint_range_max),
"\nTreatment Variable Faceting:",
input$trt_facet,
"\nRegression Line:",
input$reg_line
card_fun <- function(comment, label) {
constraint_description <- paste(
"\nTreatment Variable Faceting:",
input$trt_facet,
"\nRegression Line:",
input$reg_line
)
card <- report_card_template_goshawk(
title = "Scatter Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api,
constraint_list = list(
constraint_var = input$constraint_var,
constraint_range_min = input$constraint_range_min,
constraint_range_max = input$constraint_range_max
),
constraint_description = constraint_description,
style = "verbatim"
)
card$append_text("Scatter Plot", "header3")
Expand Down
19 changes: 11 additions & 8 deletions R/tm_g_gh_spaghettiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,17 @@ srv_g_spaghettiplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Spaghetti Plot")
card$append_text("Spaghetti Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card$append_text("Selected Options", "header3")
card$append_text(
formatted_data_constraint(input$constraint_var, input$constraint_range_min, input$constraint_range_max)
card_fun <- function(comment, label) {
card <- report_card_template_goshawk(
title = "Spaghetti Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api,
constraint_list = list(
constraint_var = input$constraint_var,
constraint_range_min = input$constraint_range_min,
constraint_range_max = input$constraint_range_max
)
)
card$append_text("Spaghetti Plot", "header3")
card$append_plot(plot_r(), dim = plot_data$dim())
Expand Down
2 changes: 1 addition & 1 deletion R/utils-data_constraints.r
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ create_anl_constraint_reactive <- function(anl_param, input, param_id, min_rows)
)
}

# for outputting the constaint in the report
# for outputting the constraint in the report
formatted_data_constraint <- function(constraint_var, constraint_range_min, constraint_range_max) {
constraint_var_label <- switch(constraint_var,
"BASE2" = "Screening",
Expand Down
51 changes: 51 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,54 @@ plots_per_row_validate_rules <- function(required = TRUE) {
shinyvalidate::sv_gt(0, message_fmt = msg)
)
}

#' Template Function for `TealReportCard` Creation and Customization in `teal.goshawk`
#'
#' This function generates a report card with a title,
#' an optional description, and the option to append the filter state list.
#' Additionally, it display selected constraint options.
#'
#' @inheritParams teal.reporter::card_template
#' @param constraint_list (`list`) a list containing constraint variables, including:
#' - constraint_var (`character(1)`) the constraint variable name.
#' - constraint_range_min (`numeric(1)`) the minimum constraint range value.
#' - constraint_range_max (`numeric(1)`) the maximum constraint range value.
#' @param constraint_description (`character(1)`) description of the constraints.
#' @param style (`character(1)`) style of the constraint text block.
#' options: `default`, `verbatim` (default is `default`).
#'
#' @return (`TealReportCard`) populated with a title, description, and filter state
#'
#' @keywords internal
report_card_template_goshawk <- function(title,
label,
with_filter,
filter_panel_api,
constraint_list,
constraint_description = NULL,
style = "default") {
checkmate::assert_subset(names(constraint_list), c("constraint_var", "constraint_range_min", "constraint_range_max"))
checkmate::assert_string(constraint_description, null.ok = TRUE)
checkmate::assert_choice(style, c("default", "verbatim"))

card <- teal::report_card_template(
title = title,
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)

card$append_text("Selected Options", "header3")
card$append_text(
paste(
formatted_data_constraint(
constraint_list$constraint_var,
constraint_list$constraint_range_min,
constraint_list$constraint_range_max
),
constraint_description
),
style = style
)
card
}
38 changes: 38 additions & 0 deletions man/report_card_template_goshawk.Rd

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