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.
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)
When using the default
width = 100%
forplotlyOutput()
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 multipletabItems()
. Minimal example and a GIF to better explain what I mean below. Posting it here, but please advise if this should be anhtmlwidgets
orshiny
issue instead.