echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

e_brush arguments ... not working

Open augustoamerico opened this issue 6 years ago • 1 comments

I'm trying to input the option throttleType = "debounce" on e_brush but it doesn't seem to be working.

Reproducible example:

   library(shiny)
   
     ui <- fluidPage(
         actionButton("add", "Add Data to y"),
         echarts4rOutput("plot"),
         h4("Brush"),
         verbatimTextOutput("selected"),
         h4("Legend select change"),
         verbatimTextOutput("legend")
       )
     
       server <- function(input, output, session){
         
             data <- data.frame(x = rnorm(10, 5, 3), y = rnorm(10, 50, 12), z = rnorm(10, 50, 5))
             
               react <- eventReactive(input$add, {
                   set.seed(sample(1:1000, 1))
                   data.frame(x = rnorm(10, 5, 2), y = rnorm(10, 50, 10))
                 })
               
                 output$plot <- renderEcharts4r({
                     data %>% 
                        e_charts(x) %>% 
                        e_scatter(y) %>%
                        e_scatter(z) %>% 
                        e_brush(throttleType = "debounce")
                   })
                 
                   observeEvent(input$add, {
                       echarts4rProxy("plot") %>% 
                           e_append1_p(0, react(), x, y)
                     })
                 
                   output$selected <- renderPrint({
                       input$plot_brush
                     })
                   
                     output$legend <- renderPrint({
                         input$plot_legend_change
                       })
                     
                     }
       
         shinyApp(ui, server)

Am I doing something wrong, or this was not yet implemented?

Thanks!

augustoamerico avatar Jul 26 '19 11:07 augustoamerico

@augustoamerico, it will help if you describe your expectations and why "it doesn't seem to be working".

From my understanding the purpose of debounce is to make sure mouse movement has finished and it is safe to make/report the selection. Waiting is defined by parameter throttleDelay, which defaults to 0 (=disabled). That's why your code shows the selected values instantly without delay. After adding a value of 3000 for throttleDelay,

e_brush(throttleType = "debounce", throttleDelay=3000)

you'll notice a 3 seconds delay after selection, which means "debounce" is working.

helgasoft avatar Jul 29 '20 05:07 helgasoft