【问题标题】:Embedding Image in Shiny App在闪亮的应用程序中嵌入图像
【发布时间】:2014-03-26 15:42:12
【问题描述】:

我一直在开发一个闪亮的应用程序,并希望在应用程序的右上角包含一个徽标。如何使用 shiny 和 r 轻松嵌入图像?

谢谢! 克

【问题讨论】:

    标签: r embed shiny


    【解决方案1】:

    使用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;
    }
    

    【讨论】:

      【解决方案2】:

      我找到了另一个看起来很适合此应用的选项,因此我将分享给其他想要在主面板中显示图像的人。

      mainPanel(
         img(src='myImage.png', align = "right"),
        ### the rest of your code
        )
      

      将文件保存在 shinyApp 目录中的 www 目录中:

       | shinyApp/
          | ui.R
          | server.R
          | www/
             | myImage.png
      

      【讨论】:

        猜你喜欢
        • 2018-10-25
        • 2016-01-06
        • 1970-01-01
        • 1970-01-01
        • 2018-01-06
        • 2019-01-08
        • 2018-11-09
        • 1970-01-01
        相关资源
        最近更新 更多