plotly / plotly/plotly.R

Shiny plotly sizing issue for plotlyOutput() when width = 100%

未关闭
#1,827 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

When using the default width = 100% for plotlyOutput() in Shiny apps, I always run into issues where the width doesn't scale to the full width when clicking away before the plot is fully rendered. When clicking back, the plot's width doesn't adjust or rescale. This setting occurs often in practice when designing a shinydashboard with multiple tabItems(). Minimal example and a GIF to better explain what I mean below. Posting it here, but please advise if this should be an htmlwidgets or shiny issue instead.

plotlyOutput

library(shiny)
library(plotly)

ui <- navbarPage(
  title = "Minimal Example",
  tabPanel("Home", HTML("Click the `Plot` tab and then rapidly back on the `Home` tab. Wait 2 seconds and then click the `Plot` tab again.")),
  tabPanel("Plot", plotlyOutput("plot"))
)

server <- function(input, output) {
  output$plot <- renderPlotly({
    Sys.sleep(2)
    plot_ly(iris, x = ~Sepal.Width, y = ~Sepal.Length, type = "scatter", mode = "markers")
  })
}

shinyApp(ui, server)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先运行提供的最小 R Shiny 示例,并使用 plotlyOutput() 和 renderPlotly() 重现切换选项卡时的行为。调查尺寸问题属于 plotly.R、htmlwidgets 还是 Shiny;完成的标准是:即使渲染被延迟,返回该选项卡后绘图也会扩展到完整宽度。

由索引模型根据 Issue 内容生成。

评估

技术栈
plotly, r
领域
data-visualization, frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。