向ShinyDashboard标题添加公司徽标
好奇的是,有没有办法在ShinydaShashboard的页眉上添加公司标志?正如我所看到的,它描述了更改CSS中的“logo”,这只是配置左上角的内容,尽管据我所知,我希望保留我的标题 我没有使用下拉菜单,因此我想在右上角的红色框中添加我的公司徽标 有人知道Shinydashboard如何做到这一点吗?谢谢 更新2020-10-27向ShinyDashboard标题添加公司徽标,r,shiny,shinydashboard,R,Shiny,Shinydashboard,好奇的是,有没有办法在ShinydaShashboard的页眉上添加公司标志?正如我所看到的,它描述了更改CSS中的“logo”,这只是配置左上角的内容,尽管据我所知,我希望保留我的标题 我没有使用下拉菜单,因此我想在右上角的红色框中添加我的公司徽标 有人知道Shinydashboard如何做到这一点吗?谢谢 更新2020-10-27 对于那些熟悉HTML或希望用户界面更灵活的用户,以及能够访问前端开发人员的用户,我最近发现可以使用HTML构建整个用户界面。有一篇关于它的精彩文章。这将允许整个
对于那些熟悉HTML或希望用户界面更灵活的用户,以及能够访问前端开发人员的用户,我最近发现可以使用HTML构建整个用户界面。有一篇关于它的精彩文章。这将允许整个品牌和布局的方式,可以符合您的公司标准,如果需要的话。希望这能有所帮助。我一直在为此而努力(我知道你没有要求它,但这里有一个可点击的徽标,我们正在进行此操作): 或者,为徽标添加一点魔力(我也使用我的徽标作为加载条):
#获取位置'href',图像位置'src',加载gif'loadingsrc'
#高度、宽度和alt文本,并生成一个加载徽标,在
#她很忙
加载logo这是我的破解方法(如前所述,将您的logo放入应用程序目录的www
子目录中)。
由于dashboardHeader()
需要类型为li
和类为dropdown
的标记元素,因此我们可以传递这些元素,而不是dropdown menu
s:
library(shiny)
library(shinydashboard)
dbHeader <- dashboardHeader(title = "My Dashboard",
tags$li(a(href = 'http://shinyapps.company.com',
icon("power-off"),
title = "Back to Apps Home"),
class = "dropdown"),
tags$li(a(href = 'http://www.company.com',
img(src = 'company_logo.png',
title = "Company Home", height = "30px"),
style = "padding-top:10px; padding-bottom:10px;"),
class = "dropdown"))
server <- function(input, output) {}
shinyApp(
ui = dashboardPage(
dbHeader,
dashboardSidebar(),
dashboardBody()
),
server = server
)
库(闪亮)
图书馆(shinydashboard)
dbHeader这可能会有所帮助。我怎样才能改变logo的对齐方式呢?这将是css样式。有两种方法可以做到这一点,一种是用标记$style(..)包装子项。另一种方法(可能是首选方法)是创建一个custom.css文件并将其放入/www/文件夹中。然后用标签$head调用它(标签$link(rel=“stylesheet”,type=“text/css”,href=“custom.css”)
。在样式表中只需添加。logo{ALIGNMENTPARAMS:VALUE;}
您可以通过google找到参数和值的名称。@Shape with shiny 0.13.2和shinydashboard 0.5.1解决方案似乎不起作用:我得到服务器的响应状态为404(未找到)
@Enzo这些都是我的版本,它仍然适用于我,确保链接正确并且logo.png在你的www文件夹中。我发现了问题:你需要有单独的ui.R和server.R文件,否则如果你在一个app.R文件中与shinyApp(ui,server)一起使用,它在www文件夹中找不到logo.png文件(但它确实找到了我的favicon.ico-boh?)。如果有人不需要点击它,我建议将a()
更改为div()
,并将margin right:10px;
添加到样式参数中。由于浏览器处理中最近的规则更改,需要对img进行微小更改。将img(src=…)
更改为tags$img(src=…)
。图像的大小与此有关吗?
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()
)
library(shiny)
library(shinydashboard)
dbHeader <- dashboardHeader(title = "My Dashboard",
tags$li(a(href = 'http://shinyapps.company.com',
icon("power-off"),
title = "Back to Apps Home"),
class = "dropdown"),
tags$li(a(href = 'http://www.company.com',
img(src = 'company_logo.png',
title = "Company Home", height = "30px"),
style = "padding-top:10px; padding-bottom:10px;"),
class = "dropdown"))
server <- function(input, output) {}
shinyApp(
ui = dashboardPage(
dbHeader,
dashboardSidebar(),
dashboardBody()
),
server = server
)