plotly plot rendering squished when switching tabs quickly in shinydashboard
まだ誰も着手していません。
- 主要言語
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、plotlyOutput と renderPlotly の呼び出しを含む提供された Shiny reprex を実行し、次にプロットがレンダリングされる前にタブを切り替える操作を再現します。動作をリンクされた 2 件の Stack Overflow の報告と比較します。完了条件は、現在の workaround なしで、タブをすばやく切り替えた後もプロットが意図したサイズを維持することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- r
- 領域
- data-visualization, frontend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100