gpt4 book ai didi

css - 如何将公司 Logo 添加到 ShinyDashboard 标题(不是 mainPanel 或 mainHeader)

转载 作者:技术小花猫 更新时间:2023-10-29 11:53:52 26 4
gpt4 key购买 nike

我试图引用以下答案,但 Logo 位于主面板内而不是标题面板内......有什么解决方案吗?

HeaderLogo

我看到了DISTRIBUTIONS OF RANDOM VARIABLES在主面板的标题中有一个 Logo ,但无法在 shinyDashboard 标题中工作。以下是公司 Logo 标题的编码:

headerPanel(
HTML('Distributions of Random Variables v4
<a href="http://snap.uaf.edu" target="_blank"><img align="right" alt="SNAP Logo" src="./img/SNAP_acronym_100px.png" /></a>'
), "Distributions of Random Variables"
),

下面是我添加公司标志和source codes的代码在这儿。有什么想法吗?

dbHeader <- dashboardHeader(title = 'Reporting Dashboard',
dropdownMenuOutput('messageMenu'),
dropdownMenu(type = 'notifications',
notificationItem(text = '5 new users today', icon('users')),
notificationItem(text = '12 items delivered',
icon('truck'), status = 'success'),
notificationItem(text = 'Server load at 86%',
icon = icon('exclamation-triangle'),
status = 'warning')),
dropdownMenu(type = 'tasks',
badgeStatus = 'success',
taskItem(value = 90, color = 'green', 'Documentation'),
taskItem(value = 17, color = 'aqua', 'Project X'),
taskItem(value = 75, color = 'yellow', 'Server deployment'),
taskItem(value = 80, color = 'red', 'Overall project')))
dbHeader$children$children <- HTML("<a href='http://www.scibrokes.com' target='_blank'>
<img align='right' alt='Logo' src='./oda-army.jpg'/></a>")

最佳答案

解决方案是隐藏您的图像,这样 Shiny 就可以像呈现普通dropdownMenu 元素一样呈现它。

正如您可能从控制台看到的那样,dashboardHeader 抛出错误

Error in FUN(X[[i]], ...) : Expected tag to be of type li

如果您尝试插入任何 自定义 HTML。如果您选择 li 标签,它甚至会详细说明

Error in FUN(X[[i]], ...) : Expected tag to have class 'dropdown'

这是你的交易,将你的图像添加到 lidropdown 包装器中,你就可以开始了。

示例代码:

library(shinydashboard)
library(shiny)

runApp(
shinyApp(
ui = shinyUI(
dashboardPage(
dashboardHeader(title = 'Reporting Dashboard',
tags$li(class = "dropdown",
tags$a(href="http://snap.uaf.edu", target="_blank",
tags$img(height = "20px", alt="SNAP Logo", src="https://www.snap.uaf.edu/sites/default/files/pictures/snap_symbol_color.png")
)
),
dropdownMenuOutput('messageMenu'),
dropdownMenu(type = 'notifications',
notificationItem(text = '5 new users today', icon('users')),
notificationItem(text = '12 items delivered',
icon('truck'), status = 'success'),
notificationItem(text = 'Server load at 86%',
icon = icon('exclamation-triangle'),
status = 'warning')),
dropdownMenu(type = 'tasks',
badgeStatus = 'success',
taskItem(value = 90, color = 'green', 'Documentation'),
taskItem(value = 17, color = 'aqua', 'Project X'),
taskItem(value = 75, color = 'yellow', 'Server deployment'),
taskItem(value = 80, color = 'red', 'Overall project'))
),

dashboardSidebar(),
dashboardBody()
)
),

server = function(input, output){}

), launch.browser = TRUE
)

希望这对您有所帮助!

关于css - 如何将公司 Logo 添加到 ShinyDashboard 标题(不是 mainPanel 或 mainHeader),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35961970/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com