【发布时间】:2021-11-02 23:21:46
【问题描述】:
我有一个闪亮的应用程序,完全构建,我在一个脚本中构建了所有内容。一切正常,用户界面等,我想模块化应用程序以使代码更具可读性。现在所有的情节都呈现在彼此之上,我不知道为什么。我尝试过使用 pageContainer、sidbarLayout、sidePanel 和 mainPanel、fluidPage、fixedPage 等,但都没有奏效。我也在我的主 ui 中使用 pagePiling,所以不确定这是否有时与它有关?任何帮助将非常感激! 请在此处找到完整代码:https://github.com/eoefelein/COVID_Business_Recovery_and_Social_Capital/tree/master/socialCapitalEmployment
ui <- tagList(
pagePiling(
center = TRUE,
sections.color = c("#3333FF", "#E6E6E6"),
menu = c(
"Home" = "home",
"Map" = "map",
"Series" = "ts",
"PCA" = "pca",
"Predict" = "predict",
"About" = "about"
),
pageSectionImage(
center = TRUE,
img = "",
menu = "home",
h1(("title"), class = "header shadow-dark"),
h3(
class = "light footer",
"by",
tags$a("news-r", href = "https://news-r.org", class = "link")
)
),
pageSection(center = TRUE,
menu = "map",
mod_map_ui("map"),
br()),
pageSection(center = TRUE,
menu = "ts",
mod_ts_ui("ts"),
br()),
pageSection(center = TRUE,
menu = "pca",
mod_pca_ui("pca"),
br()),
pageSection(
center = TRUE,
menu = "predict",
mod_predict_ui("predict"),
),
pageSection(
center = TRUE,
menu = "about",
h1("About", class = "header shadow-dark"),
h2(
class = "shadow-light",
tags$a(
"The code",
href = "https://github.com/news-r/fopi.app",
target = "_blank",
class = "link"
),
"|",
tags$a(
"The API",
href = "https://github.com/news-r/fopi",
target = "_blank",
class = "link"
)
),
h3(
class = "light footer",
"by",
tags$a("news-r", href = "https://news-r.org", class = "link")
)
)
)
)
这是我的第一个模块的用户界面:
mod_map_ui <- function(id) {
ns <- NS(id)
tagList(
fluidPage(
h1("Employment & Social Capital across the U.S by County"),
center = TRUE,
column(9, leafletOutput(ns("map"), height = "100vh")),
column(
3,
shinyWidgets::radioGroupButtons(
inputId = ns("idx"),
label = "Metric",
choices = c(unique(social_indices$name)),
checkIcon = list(yes = icon("ok",
lib = "glyphicon"))
)
)
))
}
这是我的第二个模块的用户界面:
mod_ts_ui <- function(id) {
ns <- NS(id)
tagList(
fixedPage(
h2("Employment by County", align = "center"),
fixedRow(
column(
4,
selectizeInput(
inputId = ns("dataset"),
label = "Choose a county:",
choices = c(unique(employment["countyfips"])),
multiple = TRUE,
selected = "Travis County, Texas",
options = list(create = TRUE)
)
),
column(
8, (echarts4r::echarts4rOutput(ns("ts_plot")))
)
)
)
)
}
【问题讨论】:
-
或许您应该发布完整的MRE 以便有人可以帮助您。
-
@YBS 这里是上传到 github 的完整代码的链接。谢谢你的帮助! github.com/eoefelein/COVID_Business_Recovery_and_Social_Capital/…
-
很确定这个问题来自
pagePiling,而不是通常的fluidPage等等。 -
对于绘图,您可以使用
pageSectionPlot(),而不是pageSection()。
标签: r user-interface shiny module