将Weather iframe嵌入“闪亮的信息中心" [英] Embed weather iframe into Shiny Dashboard

查看:103
本文介绍了将Weather iframe嵌入“闪亮的信息中心"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将来自Forecast.io的天气预报嵌入到一个闪亮的仪表板中.我最初在&符上遇到麻烦,但是看到了一篇帖子,提供了有关如何使用特殊字符格式化HTML代码的示例.但是,当我运行该应用程序时,即使我知道该链接有效并且已正确设置格式,我也会看到一个简单的未找到".我不确定我缺少什么.

I am trying to embed the weather forecast from forecast.io in a Shiny dashboard. I originally had trouble with the ampersand but saw a post that provided an example of how to format HTML code with special characters. However, when I run the app I see a simple "Not Found", even though I know that the link works and is being formatted correctly. I'm not sure what I'm missing.

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Dashboard"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
    )
  ),

  dashboardBody(
    tabItems(
      # First tab content
      tabItem(tabName = "dashboard",
              fluidRow(

                column(12,
                       mainPanel(htmlOutput("frame")
                       )
                )
              )
      )
    )
  )
)

server <- shinyServer(function(input, output) {

  output$frame <- renderUI({
    tags$iframe(id = 'app', src = url("https://forecast.io/embed/#lat=42.3583&lon=-71.0603&name=Downtown Boston"), width = '100%')
  })

})

shinyApp(ui,server)

闪亮信息中心"中的错误的屏幕截图

推荐答案

使用插入的仪表板进行更新

我已将网址从服务器传输到ui:

I transfered url from server to ui:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
    dashboardHeader(title = "Dashboard"),
    dashboardSidebar(
        sidebarMenu(
            menuItem("Dashboard", 
                     tabName = "dashboard", 
                     icon = icon("dashboard")
            )
        )
    ),

    dashboardBody(
        tabItems(
            tabItem(
                tabName = "dashboard",
                fluidRow(
                    tags$iframe(
                        seamless = "seamless", 
                        src = "https://forecast.io/embed/#lat=42.3583&lon=-71.0603&name=Downtown Boston", 
                        height = 800, width = 1400
                    )
                )
            )
        )
    )
)

server <- function(input, output) {}
shinyApp(ui, server)

这篇关于将Weather iframe嵌入“闪亮的信息中心"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆