plotly plot rendering squished when switching tabs quickly in shinydashboard
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza ejecutando el reprex de Shiny proporcionado con sus llamadas a plotlyOutput y renderPlotly, y luego reproduce el cambio de pestañas antes de que se rendericen los gráficos. Compara el comportamiento con los dos informes enlazados de Stack Overflow; se considera terminado cuando los gráficos conservan su tamaño previsto después de cambiar rápidamente de pestaña, sin el workaround actual.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization, frontend
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100