Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate an Index.html file in shiny with plotly? #119

Open
David-Degnan opened this issue May 25, 2022 · 0 comments
Open

Generate an Index.html file in shiny with plotly? #119

David-Degnan opened this issue May 25, 2022 · 0 comments

Comments

@David-Degnan
Copy link

David-Degnan commented May 25, 2022

Hello! We are building a shiny application that generates trelliscope displays. Due to security issues when we deploy the app, we must keep jsonp = FALSE. Plotly graphics only display when self_contained = FALSE; however, no Index.html file is generated. If we pipe it to the print function, the generated Index.html does not visualize correctly (no plots). We want to provide users the capability ot download a standalone trelliscope from the app (thus the need for the Index.html file). Is there a way to generate an Index.html file in shiny with plotly while keeping jsonp=FALSE?Thanks. I am on version 0.2.10. Below is some example code I was using:

library(shiny)
library(plotly)
library(dplyr)
library(tidyr)
library(trelliscopejs)

data("iris")

ui <- fluidPage(
    sidebarLayout(
        sidebarPanel(
          selectInput("xlab", "X Label", colnames(iris)[1:4], selected = colnames(iris)[1]),
          selectInput("ylab", "Y Label", colnames(iris)[1:4], selected = colnames(iris)[2]),
          textInput("theName", "Trelliscope Name", "name"),
          selectInput("selfcontained", "Self Contained?", c("TRUE", "FALSE"), "TRUE")
        ),
        mainPanel(
            trelliscopeOutput("TestTrelli")
        )
    )
)

server <- function(input, output, session) {
  
  output$TestTrelli <- renderTrelliscope({

    iris %>% 
      group_by(Species) %>%
      nest() %>%
      mutate(
        panel = map_plot(data, function(data) {
          plot_ly(x = data[[input$xlab]], y = data[[input$ylab]], type = "scatter", mode = "markers")
        })
      ) %>%
      ungroup() %>%
      trelliscope(path = "www/trelli", name = input$theName, self_contained = as.logical(input$selfcontained), jsonp = FALSE, thumb = TRUE)

  })
    
}

# Run the application 
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant