plotly html embedded in shiny2019 Community Moderator ElectionWhat are valid values for the id attribute in HTML?Recommended way to embed PDF in HTML?Convert HTML + CSS to PDF with PHP?HTML 5: Is it <br>, <br/>, or <br />?How to create an HTML button that acts like a link?Redirect from an HTML pageWhy does HTML think “chucknorris” is a color?What is the purpose of the “role” attribute in HTML?Embedding a dynamically changing R htmlwidget into a webpageGenerate flexdashboard in Rmarkdown

If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?

When to use a slotted vs. solid turner?

Is a party consisting of only a bard, a cleric, and a warlock functional long-term?

Why one should not leave fingerprints on bulbs and plugs?

Why is a white electrical wire connected to 2 black wires?

Knife as defense against stray dogs

Brexit - No Deal Rejection

Why Choose Less Effective Armour Types?

Happy pi day, everyone!

Did Ender ever learn that he killed Stilson and/or Bonzo?

What is a ^ b and (a & b) << 1?

How could an airship be repaired midflight?

Non-trivial topology where only open sets are closed

Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible

Describing a chess game in a novel

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

Is it good practice to use Linear Least-Squares with SMA?

Does multi-classing into Fighter give you heavy armor proficiency?

Is it normal that my co-workers at a fitness company criticize my food choices?

What are substitutions for coconut in curry?

How to make healing in an exploration game interesting

Four married couples attend a party. Each person shakes hands with every other person, except their own spouse, exactly once. How many handshakes?

Fastest way to pop N items from a large dict

How to write cleanly even if my character uses expletive language?



plotly html embedded in shiny



2019 Community Moderator ElectionWhat are valid values for the id attribute in HTML?Recommended way to embed PDF in HTML?Convert HTML + CSS to PDF with PHP?HTML 5: Is it <br>, <br/>, or <br />?How to create an HTML button that acts like a link?Redirect from an HTML pageWhy does HTML think “chucknorris” is a color?What is the purpose of the “role” attribute in HTML?Embedding a dynamically changing R htmlwidget into a webpageGenerate flexdashboard in Rmarkdown










0















I have generated few plots using plotly and saved them as offline html (I don't want to generate them live as it would take so long to generate them in the background). The followings are the two plots taken from plotly site and I saved them as html.



#Graph 1
Animals <- c("giraffes", "orangutans", "monkeys")
SF_Zoo <- c(20, 14, 23)
LA_Zoo <- c(12, 18, 29)
data <- data.frame(Animals, SF_Zoo, LA_Zoo)

p <- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>%
add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
layout(yaxis = list(title = 'Count'), barmode = 'group')

htmlwidgets::saveWidget(p, file="zoo.html")


#Graph 2
x <- c('Product A', 'Product B', 'Product C')
y <- c(20, 14, 23)
text <- c('27% market share', '24% market share', '19% market share')
data <- data.frame(x, y, text)

p <- plot_ly(data, x = ~x, y = ~y, type = 'bar', text = text,
marker = list(color = 'rgb(158,202,225)',
line = list(color = 'rgb(8,48,107)',
width = 1.5))) %>%
layout(title = "January 2013 Sales Report",
xaxis = list(title = ""),
yaxis = list(title = ""))
htmlwidgets::saveWidget(p, file="product.html")


I have written some shiny codes that can show html output from Rmarkdown but not the html that i generated from plotly above. Note that the first choice(sample) in the selectInput() is what I generated from default Rmarkdown html and that works. I also generated multiple rmarkdown html and I could also switch between htmls in the shiny app but not for plotly html.



ui= fluidPage(
titlePanel("opening web pages"),
sidebarPanel(
selectInput(inputId='test',label=1,choices=c("sample","zoo","product"))
),
mainPanel(
htmlOutput("inc")
)
)
server = function(input, output)
getPage<-function()
return(includeHTML(paste0("file:///C:/Users/home/Documents/",input$test,".html")))

output$inc<-renderUI(getPage())

shinyApp(ui, server)









share|improve this question


























    0















    I have generated few plots using plotly and saved them as offline html (I don't want to generate them live as it would take so long to generate them in the background). The followings are the two plots taken from plotly site and I saved them as html.



    #Graph 1
    Animals <- c("giraffes", "orangutans", "monkeys")
    SF_Zoo <- c(20, 14, 23)
    LA_Zoo <- c(12, 18, 29)
    data <- data.frame(Animals, SF_Zoo, LA_Zoo)

    p <- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>%
    add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
    layout(yaxis = list(title = 'Count'), barmode = 'group')

    htmlwidgets::saveWidget(p, file="zoo.html")


    #Graph 2
    x <- c('Product A', 'Product B', 'Product C')
    y <- c(20, 14, 23)
    text <- c('27% market share', '24% market share', '19% market share')
    data <- data.frame(x, y, text)

    p <- plot_ly(data, x = ~x, y = ~y, type = 'bar', text = text,
    marker = list(color = 'rgb(158,202,225)',
    line = list(color = 'rgb(8,48,107)',
    width = 1.5))) %>%
    layout(title = "January 2013 Sales Report",
    xaxis = list(title = ""),
    yaxis = list(title = ""))
    htmlwidgets::saveWidget(p, file="product.html")


    I have written some shiny codes that can show html output from Rmarkdown but not the html that i generated from plotly above. Note that the first choice(sample) in the selectInput() is what I generated from default Rmarkdown html and that works. I also generated multiple rmarkdown html and I could also switch between htmls in the shiny app but not for plotly html.



    ui= fluidPage(
    titlePanel("opening web pages"),
    sidebarPanel(
    selectInput(inputId='test',label=1,choices=c("sample","zoo","product"))
    ),
    mainPanel(
    htmlOutput("inc")
    )
    )
    server = function(input, output)
    getPage<-function()
    return(includeHTML(paste0("file:///C:/Users/home/Documents/",input$test,".html")))

    output$inc<-renderUI(getPage())

    shinyApp(ui, server)









    share|improve this question
























      0












      0








      0








      I have generated few plots using plotly and saved them as offline html (I don't want to generate them live as it would take so long to generate them in the background). The followings are the two plots taken from plotly site and I saved them as html.



      #Graph 1
      Animals <- c("giraffes", "orangutans", "monkeys")
      SF_Zoo <- c(20, 14, 23)
      LA_Zoo <- c(12, 18, 29)
      data <- data.frame(Animals, SF_Zoo, LA_Zoo)

      p <- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>%
      add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
      layout(yaxis = list(title = 'Count'), barmode = 'group')

      htmlwidgets::saveWidget(p, file="zoo.html")


      #Graph 2
      x <- c('Product A', 'Product B', 'Product C')
      y <- c(20, 14, 23)
      text <- c('27% market share', '24% market share', '19% market share')
      data <- data.frame(x, y, text)

      p <- plot_ly(data, x = ~x, y = ~y, type = 'bar', text = text,
      marker = list(color = 'rgb(158,202,225)',
      line = list(color = 'rgb(8,48,107)',
      width = 1.5))) %>%
      layout(title = "January 2013 Sales Report",
      xaxis = list(title = ""),
      yaxis = list(title = ""))
      htmlwidgets::saveWidget(p, file="product.html")


      I have written some shiny codes that can show html output from Rmarkdown but not the html that i generated from plotly above. Note that the first choice(sample) in the selectInput() is what I generated from default Rmarkdown html and that works. I also generated multiple rmarkdown html and I could also switch between htmls in the shiny app but not for plotly html.



      ui= fluidPage(
      titlePanel("opening web pages"),
      sidebarPanel(
      selectInput(inputId='test',label=1,choices=c("sample","zoo","product"))
      ),
      mainPanel(
      htmlOutput("inc")
      )
      )
      server = function(input, output)
      getPage<-function()
      return(includeHTML(paste0("file:///C:/Users/home/Documents/",input$test,".html")))

      output$inc<-renderUI(getPage())

      shinyApp(ui, server)









      share|improve this question














      I have generated few plots using plotly and saved them as offline html (I don't want to generate them live as it would take so long to generate them in the background). The followings are the two plots taken from plotly site and I saved them as html.



      #Graph 1
      Animals <- c("giraffes", "orangutans", "monkeys")
      SF_Zoo <- c(20, 14, 23)
      LA_Zoo <- c(12, 18, 29)
      data <- data.frame(Animals, SF_Zoo, LA_Zoo)

      p <- plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo') %>%
      add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
      layout(yaxis = list(title = 'Count'), barmode = 'group')

      htmlwidgets::saveWidget(p, file="zoo.html")


      #Graph 2
      x <- c('Product A', 'Product B', 'Product C')
      y <- c(20, 14, 23)
      text <- c('27% market share', '24% market share', '19% market share')
      data <- data.frame(x, y, text)

      p <- plot_ly(data, x = ~x, y = ~y, type = 'bar', text = text,
      marker = list(color = 'rgb(158,202,225)',
      line = list(color = 'rgb(8,48,107)',
      width = 1.5))) %>%
      layout(title = "January 2013 Sales Report",
      xaxis = list(title = ""),
      yaxis = list(title = ""))
      htmlwidgets::saveWidget(p, file="product.html")


      I have written some shiny codes that can show html output from Rmarkdown but not the html that i generated from plotly above. Note that the first choice(sample) in the selectInput() is what I generated from default Rmarkdown html and that works. I also generated multiple rmarkdown html and I could also switch between htmls in the shiny app but not for plotly html.



      ui= fluidPage(
      titlePanel("opening web pages"),
      sidebarPanel(
      selectInput(inputId='test',label=1,choices=c("sample","zoo","product"))
      ),
      mainPanel(
      htmlOutput("inc")
      )
      )
      server = function(input, output)
      getPage<-function()
      return(includeHTML(paste0("file:///C:/Users/home/Documents/",input$test,".html")))

      output$inc<-renderUI(getPage())

      shinyApp(ui, server)






      html r shiny plotly






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 at 20:54









      DavesDaves

      111




      111






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can use an iframe for this - also have a look at addResourcePath:



          ui = fluidPage(
          titlePanel("opening web pages"),
          sidebarPanel(selectInput(
          inputId = 'test',
          label = 1,
          choices = c("sample", "zoo", "product")
          )),
          mainPanel(htmlOutput("inc"))
          )

          server = function(input, output)
          myhtmlfilepath <- getwd() # change to your path
          addResourcePath('myhtmlfiles', myhtmlfilepath)

          getPage <- function()
          return(tags$iframe(src = paste0("myhtmlfiles/", input$test, ".html"), height = "100%", width = "100%", scrolling = "yes"))


          output$inc <- renderUI(
          req(input$test)
          getPage()
          )


          shinyApp(ui, server)





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031977%2fplotly-html-embedded-in-shiny%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You can use an iframe for this - also have a look at addResourcePath:



            ui = fluidPage(
            titlePanel("opening web pages"),
            sidebarPanel(selectInput(
            inputId = 'test',
            label = 1,
            choices = c("sample", "zoo", "product")
            )),
            mainPanel(htmlOutput("inc"))
            )

            server = function(input, output)
            myhtmlfilepath <- getwd() # change to your path
            addResourcePath('myhtmlfiles', myhtmlfilepath)

            getPage <- function()
            return(tags$iframe(src = paste0("myhtmlfiles/", input$test, ".html"), height = "100%", width = "100%", scrolling = "yes"))


            output$inc <- renderUI(
            req(input$test)
            getPage()
            )


            shinyApp(ui, server)





            share|improve this answer



























              0














              You can use an iframe for this - also have a look at addResourcePath:



              ui = fluidPage(
              titlePanel("opening web pages"),
              sidebarPanel(selectInput(
              inputId = 'test',
              label = 1,
              choices = c("sample", "zoo", "product")
              )),
              mainPanel(htmlOutput("inc"))
              )

              server = function(input, output)
              myhtmlfilepath <- getwd() # change to your path
              addResourcePath('myhtmlfiles', myhtmlfilepath)

              getPage <- function()
              return(tags$iframe(src = paste0("myhtmlfiles/", input$test, ".html"), height = "100%", width = "100%", scrolling = "yes"))


              output$inc <- renderUI(
              req(input$test)
              getPage()
              )


              shinyApp(ui, server)





              share|improve this answer

























                0












                0








                0







                You can use an iframe for this - also have a look at addResourcePath:



                ui = fluidPage(
                titlePanel("opening web pages"),
                sidebarPanel(selectInput(
                inputId = 'test',
                label = 1,
                choices = c("sample", "zoo", "product")
                )),
                mainPanel(htmlOutput("inc"))
                )

                server = function(input, output)
                myhtmlfilepath <- getwd() # change to your path
                addResourcePath('myhtmlfiles', myhtmlfilepath)

                getPage <- function()
                return(tags$iframe(src = paste0("myhtmlfiles/", input$test, ".html"), height = "100%", width = "100%", scrolling = "yes"))


                output$inc <- renderUI(
                req(input$test)
                getPage()
                )


                shinyApp(ui, server)





                share|improve this answer













                You can use an iframe for this - also have a look at addResourcePath:



                ui = fluidPage(
                titlePanel("opening web pages"),
                sidebarPanel(selectInput(
                inputId = 'test',
                label = 1,
                choices = c("sample", "zoo", "product")
                )),
                mainPanel(htmlOutput("inc"))
                )

                server = function(input, output)
                myhtmlfilepath <- getwd() # change to your path
                addResourcePath('myhtmlfiles', myhtmlfilepath)

                getPage <- function()
                return(tags$iframe(src = paste0("myhtmlfiles/", input$test, ".html"), height = "100%", width = "100%", scrolling = "yes"))


                output$inc <- renderUI(
                req(input$test)
                getPage()
                )


                shinyApp(ui, server)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 6 at 22:45









                ismirsehregalismirsehregal

                1,7981213




                1,7981213





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031977%2fplotly-html-embedded-in-shiny%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко