这是我的闪亮 UI 代码
ui <- navbarPage(title = "Shiny-Box",
tabPanel(title = "Daily", tags$head(
tags$style(
HTML(
".custom-valuebox {
background-color: green;
}"
)
)
),
fluidPage(
fluidRow(
column(3, selectInput(inputId= "platform", "Platform", choices = c("Google", "Facebook", "LinkedIn"), selected = "Google")),
column(3, uiOutput("metric")),
column(3, uiOutput("category")),
column(3, dateRangeInput('dateRange',
label = 'Date range input: yyyy-mm-dd',
start ='2023-01-01', end = Sys.Date() + 2
)),
column(4, valueBoxOutput("value"))
),
fluidRow(
column(12, dataTableOutput("dt1"))
)
)
),
然后对于服务器代码就像:
output$value <- renderValueBox({
a <- paste0(input$platform)
b <- paste0(input$metric)
c <- paste0(input$category)
x <- paste(a,b,c)
dt1 <- switch(x,
"Facebook Lead SCN" = LeadSCN %>%
filter(Date >= input$dateRange[1] & Date <= input$dateRange[2]),
"Facebook Click SCN" = ClickSCN %>% filter(Date >= input$dateRange[1] & Date <= input$dateRange[2]),
)
sum_budget_per_day <- sum(dt1$`Budget Per Day`)
valueBox(sum_budget_per_day, "Total Budget Per Day",
icon = icon("usd"),
color = "purple",
width = 4,
div(class = "custom-valuebox"))
})
结果是这样的:
如何将每日总预算标题移至其值之上,然后如何摆脱悬停时出现的 html 行以及我的编码错误在哪里,因为背景颜色也不会变为绿色或紫色我'我试过删除 div 类,但它仍然不起作用,所以我只尝试使用 div 类,而不是颜色函数。
背景颜色正在改变