Skip to content

Commit ef79bf1

Browse files
committed
feat: keep same plot sizes in reporter as shown in modules
1 parent 2c69623 commit ef79bf1

File tree

1 file changed

+52
-54
lines changed

1 file changed

+52
-54
lines changed

R/tm_outliers.R

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,28 +1062,65 @@ srv_outliers <- function(id, data, outlier_var,
10621062
c(box_plot_q, density_plot_q, cumulative_plot_q)
10631063
)
10641064

1065-
decorated_final_q <- reactive(decorated_q[[req(current_tab_r())]]())
1065+
box_plot_r <- reactive({
1066+
teal::validate_inputs(iv_r())
1067+
req(decorated_q$box_plot())[["box_plot"]]
1068+
})
1069+
density_plot_r <- reactive({
1070+
teal::validate_inputs(iv_r())
1071+
req(decorated_q$density_plot())[["density_plot"]]
1072+
})
1073+
cumulative_plot_r <- reactive({
1074+
teal::validate_inputs(iv_r())
1075+
req(decorated_q$cumulative_plot())[["cumulative_plot"]]
1076+
})
1077+
1078+
box_pws <- teal.widgets::plot_with_settings_srv(
1079+
id = "box_plot",
1080+
plot_r = box_plot_r,
1081+
height = plot_height,
1082+
width = plot_width,
1083+
brushing = TRUE
1084+
)
1085+
1086+
density_pws <- teal.widgets::plot_with_settings_srv(
1087+
id = "density_plot",
1088+
plot_r = density_plot_r,
1089+
height = plot_height,
1090+
width = plot_width,
1091+
brushing = TRUE
1092+
)
1093+
1094+
cum_density_pws <- teal.widgets::plot_with_settings_srv(
1095+
id = "cum_density_plot",
1096+
plot_r = cumulative_plot_r,
1097+
height = plot_height,
1098+
width = plot_width,
1099+
brushing = TRUE
1100+
)
1101+
1102+
pws_list <- list(box_plot = box_pws, density_plot = density_pws, cumulative_plot = cum_density_pws)
1103+
decorated_final_q <- reactive({
1104+
set_chunk_dims(pws_list[[req(current_tab_r())]], decorated_q[[current_tab_r()]])()
1105+
})
10661106

10671107
summary_table_r <- reactive({
10681108
q <- req(decorated_final_q())
10691109

1070-
list(
1071-
html = DT::datatable(
1072-
data = if (iv_r()$is_valid()) {
1073-
categorical_var <- as.vector(merged$anl_input_r()$columns_source$categorical_var)
1074-
if (!is.null(categorical_var)) q[["summary_data"]]
1075-
},
1076-
option = list(
1077-
dom = "t",
1078-
autoWidth = TRUE,
1079-
columnDefs = list(list(width = "200px", targets = "_all"))
1080-
)
1081-
),
1082-
report = q[["table"]]
1110+
DT::datatable(
1111+
data = if (iv_r()$is_valid()) {
1112+
categorical_var <- as.vector(merged$anl_input_r()$columns_source$categorical_var)
1113+
if (!is.null(categorical_var)) q[["summary_data"]]
1114+
},
1115+
option = list(
1116+
dom = "t",
1117+
autoWidth = TRUE,
1118+
columnDefs = list(list(width = "200px", targets = "_all"))
1119+
)
10831120
)
10841121
})
10851122

1086-
output$summary_table <- DT::renderDataTable(summary_table_r()[["html"]])
1123+
output$summary_table <- DT::renderDataTable(summary_table_r())
10871124

10881125
# slider text
10891126
output$ui_outlier_help <- renderUI({
@@ -1133,45 +1170,6 @@ srv_outliers <- function(id, data, outlier_var,
11331170
}
11341171
})
11351172

1136-
box_plot_r <- reactive({
1137-
teal::validate_inputs(iv_r())
1138-
req(decorated_q$box_plot())[["box_plot"]]
1139-
})
1140-
density_plot_r <- reactive({
1141-
teal::validate_inputs(iv_r())
1142-
req(decorated_q$density_plot())[["density_plot"]]
1143-
})
1144-
cumulative_plot_r <- reactive({
1145-
teal::validate_inputs(iv_r())
1146-
req(decorated_q$cumulative_plot())[["cumulative_plot"]]
1147-
})
1148-
1149-
box_pws <- teal.widgets::plot_with_settings_srv(
1150-
id = "box_plot",
1151-
plot_r = box_plot_r,
1152-
height = plot_height,
1153-
width = plot_width,
1154-
brushing = TRUE
1155-
)
1156-
1157-
density_pws <- teal.widgets::plot_with_settings_srv(
1158-
id = "density_plot",
1159-
plot_r = density_plot_r,
1160-
height = plot_height,
1161-
width = plot_width,
1162-
brushing = TRUE
1163-
)
1164-
1165-
cum_density_pws <- teal.widgets::plot_with_settings_srv(
1166-
id = "cum_density_plot",
1167-
plot_r = cumulative_plot_r,
1168-
height = plot_height,
1169-
width = plot_width,
1170-
brushing = TRUE
1171-
)
1172-
1173-
1174-
11751173
choices <- reactive(teal.transform::variable_choices(data_obj()[[dataname_first]]))
11761174

11771175
observeEvent(common_code_q(), {

0 commit comments

Comments
 (0)