shiny icon indicating copy to clipboard operation
shiny copied to clipboard

plotOutput isn't resized when using bindEvent

Open ismirsehregal opened this issue 3 years ago • 2 comments

I'm wondering if it is expected behaviour or a bug, that base plots are no longer resized when using bindEvent even though using default width = "100%" (e.g. plotly plots are still getting resized - probably because they don't need to be re-rendered for resizing):

library(shiny)

ui <- fluidPage(
  plotOutput("goPlot", width = "100%"),
  actionButton("go", "Go")
)

server <- function(input, output, session) {
  output$goPlot <- renderPlot({
    plot(1:10)
  }) %>% bindEvent(input$go)
}

shinyApp(ui, server)

Animation

This is where I stumbled over the above. I wanted to replace eventReactive with bindEvent but the behaviour is not the same.

ismirsehregal avatar Feb 23 '22 16:02 ismirsehregal

To add to the issue, execOnResize in renderPlot does not work as well.

@ismirsehregal Before they fix this issue, I guess you can bind other events such as session$clientData[[sprintf('output_%s', session$ns("goPlot"))]] to monitor the width. However, this approach requires re-rendering the plot on resize. In some cases this could be slow.

dipterix avatar Feb 24 '22 16:02 dipterix