plotly plot rendering squished when switching tabs quickly in shinydashboard
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
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)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行提供的 Shiny reprex,其中包含 plotlyOutput 和 renderPlotly 调用,然后在图表渲染之前重现切换标签页的操作。将行为与链接的两篇 Stack Overflow 报告进行比较;完成标准是,在快速切换标签页后,图表仍保持其预期大小,而无需使用当前的 workaround。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization, frontend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100