-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zooming and dezooming in the browser makes plot be recalculated #2373
Comments
I think you're looking for output$plot <- renderPlot(execOnResize = FALSE, {
hist(iris[sample(1:150, 10),]$Sepal.Width)
}) |
Hey @cpsievert, Thanks a lot for the trick, but the issue is not with Here's the difference (no re-execution on windows resizing, but re-execution on zoom) |
The redraw happens because when you press ctrl-+ or -, the browser reports that the width of the plotOutput div has changed. The library(shiny)
shinyApp(
basicPage(plotOutput('plot')),
function(input, output, session){
output$plot <- renderPlot(execOnResize = FALSE, {
message("running renderPlot")
hist(iris[sample(1:150, 10),]$Sepal.Width)
})
}
) Even though the user code (that is, the code that you provide to If you want to avoid redraws and re-execution, see |
Hi @wch , I am also experiencing something like described; when I ctrl+mouse-wheel to zoom in on my app, all of my plots are invalidated and re-drawn, but this doesn't happen if I just resize the browser area. I have a case where my app starts and there are no cached plots, and so I'm not entirely sure how to handle that. Regardless, I have tried The solution provided by @ColinFay in his original post (putting the plot data into its own reactive context) did the trick. I'm pretty new to the reactive world, and I'm wondering if this behaviour is because Shiny simply treats the zoom event a bit differently than a resize event? I understand this issue is closed... please let me know if I should post this elsewhere! |
I think this is somehow related to #937, but if you open a Shiny App and zoom / dezoom with ctrl + and ctrl -, the plot is recalculated, which can make the UX bad for (relatively) time-consuming plots.
Minimal reprex :
Then in the browser, when I zoom dezoom, a new plot is drawn.
You can still prevent with:
But is it something that could be natively prevented?
The text was updated successfully, but these errors were encountered: