admin管理员组文章数量:1400201
I am testing a modal in the Shiny app I am developing. I noticed that when the modal opens or closes, the plotOutput briefly resizes, which is a bit distracting.
I'd like to ensure that users are not distracted by minor visual shifts like this. I am wondering how to prevent plotOutput from resizing when the modal appears or disappears in Shiny.
The minimal reproducible example is attached below:
library(shiny)
library(bslib)
library(ggplot2)
ui <- page_fillable(
theme = bs_theme(version = 5),
div(
tags$span(
style = "vertical-align: bottom;",
actionButton("b", "", icon = icon("question"))
)
),
card(
plotOutput(outputId = "iris")
)
)
server <- function(input, output, session) {
observeEvent(input$b, {
showModal(
modalDialog(
title = "Somewhat important message",
card(
card_header("Placeholder")
),
easyClose = TRUE,
size = "l",
footer = modalButton("Ok")
))
})
output$iris <- renderPlot({
iris |>
ggplot(aes(x = Sepal.Length, y = Sepal.Width, colour = Species)) +
geom_line() +
theme_minimal()
})
}
shinyApp(ui, server)
I am testing a modal in the Shiny app I am developing. I noticed that when the modal opens or closes, the plotOutput briefly resizes, which is a bit distracting.
I'd like to ensure that users are not distracted by minor visual shifts like this. I am wondering how to prevent plotOutput from resizing when the modal appears or disappears in Shiny.
The minimal reproducible example is attached below:
library(shiny)
library(bslib)
library(ggplot2)
ui <- page_fillable(
theme = bs_theme(version = 5),
div(
tags$span(
style = "vertical-align: bottom;",
actionButton("b", "", icon = icon("question"))
)
),
card(
plotOutput(outputId = "iris")
)
)
server <- function(input, output, session) {
observeEvent(input$b, {
showModal(
modalDialog(
title = "Somewhat important message",
card(
card_header("Placeholder")
),
easyClose = TRUE,
size = "l",
footer = modalButton("Ok")
))
})
output$iris <- renderPlot({
iris |>
ggplot(aes(x = Sepal.Length, y = Sepal.Width, colour = Species)) +
geom_line() +
theme_minimal()
})
}
shinyApp(ui, server)
Share
Improve this question
edited Mar 26 at 8:16
Grasshopper_NZ
asked Mar 26 at 6:23
Grasshopper_NZGrasshopper_NZ
8875 silver badges15 bronze badges
1 Answer
Reset to default 1The problem is with page_fillable
, try page_fixed
instead.
If you want to keep the fillable behavior of the components, but want to isolate the plotly-Output, you can wrap it like
card(
htmltools::div(style="height:900px !important;", plotOutput(outputId = "iris", height="900px"))
)
本文标签: rHow to prevent plotOutput from resizing when a modal opens or closes in ShinyStack Overflow
版权声明:本文标题:r - How to prevent plotOutput from resizing when a modal opens or closes in Shiny? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744162008a2593382.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论