首页 > 解决方案 > 在社交媒体上分享闪亮的应用程序时如何控制社交分享图像和文本(使用 shinyapps.io 部署)

问题描述

当我在社交媒体上分享我的 Shinyapp 时,代码显示在标题图像下方,看起来不太好。如何控制我的 shinyapp 的社交分享图像和文本?我已经使用 shinyapps.io 部署了该应用程序。

请参阅下图作为示例:

在此处输入图像描述

应用链接:https ://regionalinnovationdatalab.shinyapps.io/Dashboard/

可以找到应用程序代码和数据的 Gitlab 链接:https ://gitlab.com/r.chappell/2019_ElectionApp_RIDL

插入标题图像的 UI 中的代码:

     ui <- shiny::fluidPage( #use fluid page so that the app adjusts to the user's screen size and device

    titlePanel(div(img(src='DATA DASHBOARD V3.png', height = 80))), #header title with image as the whole header ( must save header image in a subfolder titled 'www')
  tags$head(tags$style(
    type="text/css",
        "img {max-width: 100%; width: 100%; height: auto}" #makes image size responsive to device and screen
    )),
    theme = "journal", #selected theme from shinythemes package
   title=" RIDL: 2019 Election App", #title of web brower tab
    br(),  

标签: rshinyshinyapps

解决方案


在寻求 R 工作室支持的帮助后,他们说 java 脚本代码在发布到 shinyapps.io 时存在问题,这就是它不起作用的原因。

我最终找到了解决方法。

我改变了这段代码:

 ui <- shiny::fluidPage( #use fluid page so that the app adjusts to the user's screen size and device

    titlePanel(div(img(src='DATA DASHBOARD V3.png', height = 80))), #header title with image as the whole header ( must save header image in a subfolder titled 'www')
  tags$head(tags$style(
    type="text/css",
        "img {max-width: 100%; width: 100%; height: auto}" #makes image size responsive to device and screen
    )),

对此:

  ui<-shiny::fluidPage(
    titlePanel(div(img(src='DATA_DASHBOARD_V3.png', height = "auto", width = "100%")))),

此代码删除了之前出现的 java 脚本代码,但在共享到 facebook 时不包含缩略图。R Studio 表示他们正在解决这个问题,但目前这是一个解决方案。

在此处输入图像描述


推荐阅读