为此,我一直在研究一些技巧,(我知道你没有要求它,但这是一个可点击的徽标,而我们正在使用它):
library(shiny)
library(shinydashboard)
dbHeader <- dashboardHeader()
dbHeader$children[[2]]$children <- tags$a(href='http://mycompanyishere.com',
tags$img(src='logo.png',height='60',width='200'))
dashboardPage(
dbHeader,
dashboardSidebar(),
dashboardBody()
)
所以这在标题中嵌套了一个 shiny.tag 。这个特殊闪亮对象中的第二个插槽是徽标插槽(您需要在应用目录的 /www/ 文件夹中添加一个“logo.png”)
编辑:
我刚刚检查过,从现在开始,应该不再需要这种 hack,您可以通过title=
参数直接从 dashboardHeader 函数插入 html,(之前,该参数仅强制文本),
我认为答案可能仍然是一种有用的方法来修改现有的闪亮功能,其中的东西是硬编码的。
这是现在的方法:
dashboardPage(
dashboardHeader(title = tags$a(href='http://mycompanyishere.com',
tags$img(src='logo.png')))
或者,为徽标添加更多魔力(我还使用我的徽标作为加载栏):
# Takes a location 'href', an image location 'src', a loading gif 'loadingsrc'
# height, width and alt text, and produces a loading logo that activates while
# Shiny is busy
loadingLogo <- function(href, src, loadingsrc, height = NULL, width = NULL, alt = NULL) {
tagList(
tags$head(
tags$script(
"setInterval(function(){
if ($('html').attr('class')=='shiny-busy') {
$('div.busy').show();
$('div.notbusy').hide();
} else {
$('div.busy').hide();
$('div.notbusy').show();
}
},100)")
),
tags$a(href=href,
div(class = "busy",
img(src=loadingsrc,height = height, width = width, alt = alt)),
div(class = 'notbusy',
img(src = src, height = height, width = width, alt = alt))
)
)
}
dashboardBody(
dashboardHeader(title = loadingLogo('http://mycompanyishere.com',
'logo.png',
'loader.gif'),
dashboardSidebar(),
dashboardBody()
)