我正在开发一个闪亮应用程序的用户界面......它看起来非常丑陋。我遇到三个问题:
skin = 'light'
来尝试颜色(从侧边栏开始!)。当我使用这个时,它不起作用。相反,“light”一词打印在侧边栏中。width = '450px'
添加到 header = dashboardHeader()
函数会导致 Error in FUN(X[[i]], ...) : Expected an object with class 'shiny.tag'.
错误。如何解决这三个问题?
该应用程序的代码如下:
library(shiny)
library(bs4Dash)
library(shinyWidgets)
library(plotly)
library(DT)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(
title = "Performance Indicators"
),
sidebar = dashboardSidebar(
skin = 'light',
sidebarMenu(
bs4SidebarMenuItem(tabName = "subtab1",
text = "Page 1"
# ,icon = shiny::icon("chart-bar")
),
bs4SidebarMenuItem(tabName = "subtab2",
text = "Page 2"
# ,icon = shiny::icon("chart-bar")
),
bs4SidebarMenuItem(tabName = "subtab3",
text = "Page 3"
# ,icon = shiny::icon("chart-bar")
)
)
),
body = dashboardBody(
tabItems(
tabItem(tabName = "subtab1",
fluidRow(
column(2,
box(
title = strong("Settings"),
solidHeader = TRUE,
width = 12,
dateRangeInput('dateRange',
label = 'For the time period:',
#DEFAULT
start = Sys.Date()-365, end = Sys.Date()-1),
radioButtons("time_breakdown", label = "Time period breakdown",
choices = c("Daily", "Weekly", "Monthly"),
selected = "Weekly"),
pickerInput(
inputId = "conversion_type",
label = "Conversion Type",
choices = NULL
),
pickerInput(
inputId = "first_breakdown",
label = "First breakdown:",
choices = NULL,
options = list(`actions-box` = TRUE, `live-search` = TRUE)),
pickerInput(
inputId = "sec_breakdown",
label = "Second breakdown:",
choices = NULL,
selected = "",
options = list(title = "Please select", `live-search` = TRUE))
)
),
column(6,
box(
title = strong("Page 1"),
solidHeader = TRUE,
width = 12,
plotlyOutput('graph_acq'))),
column(4,
box(
width = 12,
title = strong("MOM-YOY Breakdown"),
solidHeader = TRUE,
radioGroupButtons(
inputId = "mom_yoy_period",
label = "Time Period",
choices = c("Weekly", "Monthly"),
status = "acq_class",
selected = "Weekly"
),
DTOutput("yoy_wow"))
)
)
),
tabItem(tabName = "subtab2",
fluidRow(
column(3,
box(width = 12,
title = strong("Settings"),
solidHeader = TRUE,
pickerInput(
inputId = "week_range",
label = "Week Range",
choices = week_boundaries$description,
selected = week_boundaries$description[2]),
pickerInput(
inputId = "application_last_week",
label = "Application",
choices = NULL,
options = list(`actions-box` = TRUE, `live-search` = TRUE),
multiple = TRUE),
prettyCheckboxGroup(
inputId = "channel_last_week",
label = "Channel:",
choices = NULL,
status = "primary",
outline = TRUE,
animation = "jelly"
)
)
),
column(2,
box(width = 12,
title = "Step 1",
solidHeader = FALSE,
status = "warning",
footer = fluidRow(
column(
width = 6,
descriptionBlock(
h2('444')
)
),
column(
width = 6,
descriptionBlock(
h3('Target: 444')
)
)
)
)
),
column(2,
box(width = 12,
title = "Step 2",
solidHeader = FALSE,
status = "warning",
footer = fluidRow(
column(
width = 6,
descriptionBlock(
h2('444')
)
),
column(
width = 6,
descriptionBlock(
h3('Target: 444')
)
)
)
)
),
column(2,
box(width = 12,
title = "Step 3",
solidHeader = FALSE,
status = "warning",
footer = fluidRow(
column(
width = 6,
descriptionBlock(
h2('444')
)
),
column(
width = 6,
descriptionBlock(
h3('Target: 444')
)
)
)
)
),
column(2,
box(width = 12,
title = "Step 4",
solidHeader = FALSE,
status = "warning",
footer = fluidRow(
column(
width = 6,
descriptionBlock(
h2('444')
)
),
column(
width = 6,
descriptionBlock(
h3('Target: 444')
)
)
)
)
)
),
fluidRow(
column(6,
box(width = 12,
plotlyOutput("last_week_funnel")
)
),
column(3,
box(width = 12,
title = "Activations WOW",
solidHeader = TRUE,
DTOutput("wow_activations"))
)
)
),
tabItem(tabName = "subtab3",
fluidRow(
column(2,
box(width = 12,
title = strong("Page 3"),
solidHeader = TRUE,
dateRangeInput('dateRange_page3',
label = 'For the time period:',
start = Sys.Date()-365, end = Sys.Date()),
radioButtons("time_breakdown_first_market", label = "Time period breakdown",
choices = c("Daily", "Weekly", "Monthly"),
selected = "Daily"),
h5("Breakdown"),
pickerInput(
inputId = "first_breakdown_first_market",
label = "First breakdown:",
choices = NULL,
options = list(`actions-box` = TRUE, `live-search` = TRUE)),
pickerInput(
inputId = "sec_breakdown_first_market",
label = "Second breakdown:",
choices = NULL,
selected = "",
options = list(title = "Please select", `live-search` = TRUE))
)
),
column(10,
box(
width = 12,
height = 1200,
plotlyOutput("graph")
)
)
)
)
)
),
controlbar = dashboardControlbar()
),
server = function(input, output) {
}
)
非常感谢!
请尽量使您的示例尽可能简单且可重现。目前还没有。
这不是最小的,因为您已经包含了近 300 行代码。你真的希望我们经历这些吗?它不可重现,因为当我运行代码时它给出了
Error: object 'week_boundaries' not found
您的问题不是关于特定的 UI 元素,而是关于总体布局。所以我删除了 UI 元素并用
'p("text")
替换它们以使其变得简单。它解决了您提到的所有问题。
library(shiny)
library(bs4Dash)
library(shinyWidgets)
library(plotly)
library(DT)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(
title = "Performance Indicators"
),
sidebar = dashboardSidebar(
skin = 'light',
sidebarMenu(
bs4SidebarMenuItem(tabName = "subtab1",
text = "Page 1"
# ,icon = shiny::icon("chart-bar")
),
bs4SidebarMenuItem(tabName = "subtab2",
text = "Page 2"
# ,icon = shiny::icon("chart-bar")
),
bs4SidebarMenuItem(tabName = "subtab3",
text = "Page 3"
# ,icon = shiny::icon("chart-bar")
)
)
),
body = dashboardBody(
tabItems(
tabItem(tabName = "subtab1",
fluidRow(
column(2,p("text")),
column(6,p("text")),
column(4,p("text"))
)),
tabItem(tabName = "subtab2",
fluidRow(
column(3,p("text1")
),
column(2,p("text")),
column(2,p("text")),
column(2,p("text")),
column(2,p("text"))
),
fluidRow(
column(6,p("text")),
column(3,p("text"))
)
),
tabItem(tabName = "subtab3",
fluidRow(
column(2,p("text")),
column(10,p("text"))
)
)
)
),
controlbar = dashboardControlbar()
),
server = function(input, output) {
}
)