scatterD3
scatterD3 copied to clipboard
Freeze zoom level when adding/removing points
Is there any way to freeze the zoom level when adding/removing points to/from the scatter? Right now, the zoom level is reset every time such an action is performed. In the example below, click the zoom checkbox then the add/remove checkbox for an illustration of the issue.
library(shiny)
library(scatterD3)
my_x = rnorm(2); my_y = rnorm(2)
my_x_extra = c(my_x,my_x[1]-0.01); my_y_extra = c(my_y,my_y[1]+0.01)
ui = shinyUI(
fluidPage(
checkboxInput('zoom','zoom in/out'),
checkboxInput('point','add/remove point'),
scatterD3Output('scatterd3')
)
)
server = shinyServer(function(input, output, session) {
output$scatterd3 = renderScatterD3({
scatterD3(if(input$point){my_x_extra}else{my_x},if(input$point){my_y_extra}else{my_y},transitions=TRUE,zoom_on=if(input$zoom){c(my_x[1],my_y[1])}else{NULL},zoom_on_level=8)
})
})
shinyApp(ui=ui, server=server)
Unfortunately no, at this time there's only a small subset of changes (labels size or opacity for example) that doesn't reset the zoom. That's because most of the other changes affect the plot scales one way or another, so it is simpler to reset everything to avoid problems with the following plots. There may be a way, but it would require quite some work and rewrite that I'm not able to do for now.