【发布时间】:2022-08-17 01:01:36
【问题描述】:
我有一个闪亮的应用程序,其中标签面板(\'Drug\')显示在盒子布局之外。我正在使用闪亮的模块来模块化我的代码。 Drug 部分有一个它自己的模块,并且有一个主模块是子模块的容器。药物历史和主要模块的 UI 部分如下所示。在模块化代码之前,选项卡面板在框中显示良好。
# 药物历史模块 - UI -------------------------------------------- ---
drug_history_UI <- function(id) {
ns <- NS(id)
tabPanel(\"Drug\",
tabsetPanel(
type = \"pills\",
tabPanel(title = \"Previously Diagnosed\",
tabsetPanel(
type = \"pills\",
tabPanel(
\"Prior to Index Date\",
shinyWidgets::pickerInput(
inputId = ns(\"drug_class_selection_prev\"),
label = \"Drug Class:\",
choices = c(\"ATC 1st\", \"ATC 2nd\", \"ATC 3rd\", \"ATC 4th\", \"ATC 5th\", \"Ingredient\"),
selected = c(\"Ingredient\"),
width = \"50%\"
),
fluidRow(column(5,DT::dataTableOutput(ns(\"truven_prev_med_history_drug_table\"))),
column(7,actionButton(ns(\"resetSelection_drug_tbl_prev\"), label = \"Click to reset row selection\" ,class = \"btn-light\"),
plotlyOutput(ns(\"drug_bar_distr_plot_prev\"),height = 600),
plotlyOutput(ns(\"drug_cleveland_plot_prev\"), height = 600)),
column(12,htmlOutput(ns(\"count_pat_w_comb_trt_prev\")))
)
)
,
tabPanel(\"During Index Date\",
fluidRow(
column(5,DT::dataTableOutput(ns(\"truven_prev_med_history_drug_era_table\"))),
column(7,actionButton(ns(\"resetSelection_drug_era_tbl_prev\"), label = \"Click to reset row selection\" ,class = \"btn-light\"),
plotlyOutput(ns(\"drug_era_bar_distr_plot_prev\"),height = 600),
plotlyOutput(ns(\"drug_era_cleveland_plot_prev\"), height = 600)),
column(12, htmlOutput(ns(\"count_pat_w_comb_trt_drug_era_prev\")))
)
)
)),
tabPanel(title = \"Newly Diagnosed\",
tabsetPanel(
type = \"pills\",
tabPanel(
\"Prior to Index Date\",
shinyWidgets::pickerInput(
inputId = ns(\"drug_class_selection_new\"),
label = \"Drug Class:\",
choices = c(\"ATC 1st\", \"ATC 2nd\", \"ATC 3rd\", \"ATC 4th\", \"ATC 5th\", \"Ingredient\"),
selected = c(\"Ingredient\"),
width = \"50%\"
),
fluidRow(column(5,DT::dataTableOutput(ns(\"truven_new_med_history_drug_table\"))),
column(7,actionButton(ns(\"resetSelection_drug_tbl_new\"), label = \"Click to reset row selection\" ,class = \"btn-light\"),
plotlyOutput(ns(\"drug_bar_distr_plot_new\"),height = 600),
plotlyOutput(ns(\"drug_cleveland_plot_new\"), height = 600)),
column(12,htmlOutput(ns(\"count_pat_w_comb_trt_new\")))
)
)
,
tabPanel(\"During Index Date\",
fluidRow(
column(5,DT::dataTableOutput(ns(\"truven_new_med_history_drug_era_table\"))),
column(7,actionButton(ns(\"resetSelection_drug_era_tbl_new\"), label = \"Click to reset row selection\" ,class = \"btn-light\"),
plotlyOutput(ns(\"drug_era_bar_distr_plot_new\"),height = 600),
plotlyOutput(ns(\"drug_era_cleveland_plot_new\"), height = 600)),
column(12, htmlOutput(ns(\"count_pat_w_comb_trt_drug_era_new\")))
)
)
))
))
}
主模块
medical_history_UI <- function(id) {
ns <- NS(id)
fluidRow(
box(
h3(\"Previously Diagnosed Patients\", align = \"center\"),
h4(textOutput(ns(\"mh_prev_truven_total_projected\")), align = \"center\"),
h4(textOutput(ns(\"mh_prev_truven_total_observed\")), align = \"center\"),
width = 6
),
box(
h3(\"Newly Diagnosed Patients\", align = \"center\"),
h4(textOutput(ns(\"mh_inc_truven_total_projected\")), align = \"center\"),
h4(textOutput(ns(\"mh_inc_truven_total_observed\")), align = \"center\"),
width = 6
),
astellasTabsetPanel(
type = \"pills\",
id = \"med_history\",
# Drug Panel
drug_history_UI(ns(\"drug_history\")),
# Condition Panel
condition_UI(ns(\"condition_history\")),
# Procedure Panel
procedure_UI(ns(\"procedure_history\")),
# Charlson Comorbidity Panel
CCI_UI(ns(\"CCI\")),
tags$head(
tags$script(
\'
var dimension = [0, 0];
$(document).on(\"shiny:connected\", function(e) {
dimension[0] = window.innerWidth;
dimension[1] = window.innerHeight;
Shiny.onInputChange(\"dimension\", dimension);
});
$(window).resize(function(e) {
dimension[0] = window.innerWidth;
dimension[1] = window.innerHeight;
Shiny.onInputChange(\"dimension\", dimension);
});
\'
)
)
))
}
标签: r shiny tabs shinydashboard shinymodules