【发布时间】:2014-03-26 15:42:12
【问题描述】:
我一直在开发一个闪亮的应用程序,并希望在应用程序的右上角包含一个徽标。如何使用 shiny 和 r 轻松嵌入图像?
谢谢! 克
【问题讨论】:
我一直在开发一个闪亮的应用程序,并希望在应用程序的右上角包含一个徽标。如何使用 shiny 和 r 轻松嵌入图像?
谢谢! 克
【问题讨论】:
使用ui.R 中的自定义标头函数来引用www/ 目录中的app.css 文件:
customHeaderPanel <- function(title,windowTitle=title){
tagList(
tags$head(
tags$title(windowTitle),
tags$link(rel="stylesheet", type="text/css",
href="app.css"),
tags$h1(a(href="www.someURLlogoLinksto.com"))
)
)
}
在app.css 中引用同样位于您的www/ 文件夹中的徽标文件:
h1 {
text-decoration:none;
border:0;
width : 550px;
height : 50px;
margin : 0;
padding : 0;
left: 25px;
top: 5px;
position: relative;
background : url(logo.png) no-repeat 0 0;
}
【讨论】:
我找到了另一个看起来很适合此应用的选项,因此我将分享给其他想要在主面板中显示图像的人。
mainPanel(
img(src='myImage.png', align = "right"),
### the rest of your code
)
将文件保存在 shinyApp 目录中的 www 目录中:
| shinyApp/
| ui.R
| server.R
| www/
| myImage.png
【讨论】: