plotly / plotly/plotly.R

plotly plot rendering squished when switching tabs quickly in shinydashboard

Aperta
#1,784 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
R
Stelle
2.7k
Fork
641
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione


There seems to be an issue rendering the plots reliably when moving between tabs quickly on shinydashboard. Specifically, the plotlyOutput seems to get squished into a very thin plot when you switch away from the tab that it is on before it's rendered, and then switch back.

I found two other questions on Stack Overflow from people experiencing the same issue; one of these questions had a answer with a hacky workaround answer that I'm currently using to solve the problem. I'm including the reprex from their question (I hope the OP of the Stack Overflow question doesn't take issue with that). I've also included links to the Stack Overflow questions.

https://stackoverflow.com/questions/44587825/plotly-chart-not-rendering-correctly-in-shiny-dashboard

https://stackoverflow.com/questions/52973305/shiny-plotly-plot-stuck-when-switching-tabs-quickly
(this is the one with the reprex and the hacky solution)

For now, the hacky solution provided works alright enough for my purposes, but it's still a little bit ugly and it would be nice to have this solved more robustly.

time_waste<- function(magnitude) {
  y<-0
  for(i in 1:magnitude) {
    y<- y + rnorm(1,0,1)
  }
  return(abs(y))
}

ui <- fluidPage(sidebarLayout(
    sidebarPanel(width = 3,
                              fluidRow(
                                column(
                                  4,
                                  numericInput(
                                    inputId = "magnitude",
                                    label = "magnitude",
                                    value = 1000000
                                      )))),
    mainPanel(width = 8,
              tabsetPanel(id = "tabset",
                          tabPanel("Plot1", plotlyOutput("p1", height = "700px")),
                          tabPanel("Plot2", plotlyOutput("p2", height = "700px"))))
  )
  )

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

  y<- reactive({
    rep(time_waste(time_waste(input$magnitude)),3)
  })

  output$p1 <- renderPlotly({

  p<- plot_ly(
    x = c("giraffes", "orangutans", "monkeys"),
    y = y(),
    name = "SF Zoo",
    type = "bar"
  )
  })

  output$p2<-  renderPlotly({

    p<- plot_ly(
      x = c("giraffes", "orangutans", "monkeys"),
      y = y(),
      name = "SF Zoo",
      type = "bar"
    )

  return(p)
  })

}

app <- shinyApp(ui, server)
runApp(app)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo il reprex Shiny fornito con le relative chiamate a plotlyOutput e renderPlotly, quindi riproduci il passaggio da una scheda all’altra prima che i grafici vengano renderizzati. Confronta il comportamento con i due report collegati su Stack Overflow; il lavoro è completato quando i grafici mantengono le dimensioni previste dopo un rapido passaggio tra le schede, senza l’attuale workaround.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
r
Ambito
data-visualization, frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.