plotly / plotly/plotly.R

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

Ouverte
#1,827 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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)

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter l’exemple minimal R Shiny fourni et reproduire le comportement lors du changement d’onglet avec plotlyOutput() et renderPlotly(). Déterminez si le problème de dimensionnement se situe dans plotly.R, htmlwidgets ou Shiny ; le travail est terminé lorsque le graphique s’étend à toute la largeur après être revenu à son onglet, même lorsque le rendu a été retardé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
plotly, r
Domaine
data-visualization, frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.