Behaviour of brush parameter resetOnNew not clear to me

I do not fully understand, when resetOnNew=FALSE does actually inhibit the reset of the brush on redraw.

In my question r - brush in shiny is resetting despite resetOnNew=FALSE. What can I do about it? - Stack Overflow it says that changing the data always resets the graph.

What does that actually mean? I can somehow understand that the plot brush resets with a new aes value of x and y or with new coord_cartesian, but why is even a change of alpha or size resetting the brush? Is this a wanted behaviour or a bug?

Here you have a reprex:

library(shiny)
library(ggplot2)
library(tidyr)

ui <- fluidPage(
  plotOutput("po1", brush = brushOpts(
    "br",
    direction = "x"
  )),
  textInput("ti", "Title")
)

server <- function(input, output, session) {
  output$po1 <- renderPlot({
    pdlong <- pivot_longer(iris[1:4], !Sepal.Width)
    if (input$ti!=""){
      return(ggplot(pdlong)+geom_point(aes(x=Sepal.Width, y=value, alpha=as.numeric(name=="Petal.Length")))+scale_alpha_identity()+ggtitle(input$ti))
    } else {
      return(ggplot(pdlong)+geom_point(aes(x=Sepal.Width, y=value, alpha=as.numeric(name=="Petal.Width")))+scale_alpha_identity())
    }
  })
  observeEvent(input$br,{
    print(input$br$xmin)
    print(input$br$xmax)
    print("")
  }, ignoreNULL = FALSE)
}

shinyApp(ui, server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.