作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我试图引用以下答案,但 Logo 位于主面板内而不是标题面板内......有什么解决方案吗?
我看到了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'
这是你的交易,将你的图像添加到 li
类 dropdown
包装器中,你就可以开始了。
示例代码:
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/
我试图引用以下答案,但 Logo 位于主面板内而不是标题面板内......有什么解决方案吗? Adding a company Logo to ShinyDashboard header Embedd
我是一名优秀的程序员,十分优秀!