0

Based on the code below, how can I create a app out of an interactive HTML file? Currently, I am getting a blank app. The HTML file sits in the same folder (also set as the working directory) as the app file, do I need to put the HTML file in a separate www folder?

I already looked at Display HTML file in Shiny App and How can I display a local html file in Shiny UI dynamically?

library(shiny)

    ui <- fluidPage(
      htmlOutput("infographic")
    )
    
    server <- function(input,output){
      output$infographic <- renderUI({
        tags$iframe(seamless="seamless", 
                    src= "O:/psd/sbaloch/InfographicShinyAPp/Infographic/Hub_Infographic.html",
                    width=800, 
                    height=800)
      })
    }
    
    shinyApp(ui, server)

Approach 2 also returns a empty blank app

library(shiny)

ui <- fluidPage(
  htmlOutput("infographic")
)


server = function(input, output, session){
  output$infographic <- renderUI({
    includeHTML("O:/psd/sbaloch/InfographicShinyAPp/Infographic/Hub_Infographic.html")
    # HTML(readLines(file_to_show))
  })
  
}

shinyApp(ui, server)

enter image description here

enter image description here

Ed_Gravy
  • 1,841
  • 2
  • 11
  • 34

2 Answers2

1

The difference between your code and those in the links you provided is that you forgot to include the mainPanel in ui. Essentially, there is no connection between the user interface and the server.

Ingrid
  • 27
  • 6
0

Embedding htmlOutput in navbarPage fixed the blank app issue.

library(shiny)
library(shinydashboard)
library(shinythemes)

ui = fluidPage(
  navbarPage(htmlOutput("infographic"),
  )
)

server <- function(input,output){
  output$infographic <- renderUI({
    tags$iframe(seamless="seamless", 
                src= "Hub_Infographic.html",
                width=800, 
                height=800)
  })
}



shinyApp(ui, server)
Ed_Gravy
  • 1,841
  • 2
  • 11
  • 34