When using withSpinner() together with bslib layout functions, plots created with ggplot2 will no longer automatically fill the height of the browser.
For instance, consider this Shiny app (link to Shinylive.io):
library(shiny)
library(bslib)
library(ggplot2)
# A simple ggplot
plot_gg <- function(title) {
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
ggtitle(title)
}
ui <- page_fillable(
layout_columns(
card(plotOutput("plot1", height = "200px")),
card(plotOutput("plot2", height = "200px"))
),
card(plotOutput("plot3", height = "200px"))
)
server <- function(input, output, session) {
output$plot1 <- renderPlot(plot_gg("Plot 1"))
output$plot2 <- renderPlot(plot_gg("Plot 2"))
output$plot3 <- renderPlot(plot_gg("Plot 3"))
}
shinyApp(ui, server)
When the browser window is resized, the height of the plots is automatically adjusted to fill the entire height. This is the desired result.
If I now introduce withSpinner(), the code becomes as follows (link to Shinyapp.io), and the plots height are now predetermined and static.
library(shiny)
library(bslib)
library(ggplot2)
library(shinycssloaders)
# A simple ggplot
plot_gg <- function(title) {
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point() +
ggtitle(title)
}
ui <- page_fillable(
layout_columns(
card(withSpinner(plotOutput("plot1", height = "200px"))),
card(withSpinner(plotOutput("plot2", height = "200px")))
),
card(withSpinner(plotOutput("plot3", height = "200px")))
)
server <- function(input, output, session) {
output$plot1 <- renderPlot(plot_gg("Plot 1"))
output$plot2 <- renderPlot(plot_gg("Plot 2"))
output$plot3 <- renderPlot(plot_gg("Plot 3"))
}
shinyApp(ui, server)
Is there any built-in way to fix this behavior?
I wonder if this is related to #76, but using fill = TRUE did not help.
When using
withSpinner()together withbsliblayout functions, plots created withggplot2will no longer automatically fill the height of the browser.For instance, consider this Shiny app (link to Shinylive.io):
When the browser window is resized, the height of the plots is automatically adjusted to fill the entire height. This is the desired result.
If I now introduce
withSpinner(), the code becomes as follows (link to Shinyapp.io), and the plots height are now predetermined and static.Is there any built-in way to fix this behavior?
I wonder if this is related to #76, but using
fill = TRUEdid not help.