reactablefmtr icon indicating copy to clipboard operation
reactablefmtr copied to clipboard

slow table render when using data_bars

Open RKonstantinR opened this issue 2 years ago • 0 comments

The data_bar function is very slow in Shiny apps. For example, to display the mtcars table (32 rows) it takes about 6 seconds. On real datasets it takes much longer. This negatively impacts the user experience.

Is there a way to improve rendering speed in this case?

Attached is a reproducible example

library(shiny)
library(reactable)
library(reactablefmtr)
library(dplyr)

ui <- fluidPage(

    titlePanel("data bars"),
    
    mainPanel(
        reactableOutput("cars")
        )
    )

server <- function(input, output) {
    
    output$cars <- renderReactable({
        
        mtcars %>% 
            reactable(.,
                      groupBy = "carb",
                      defaultColDef = colDef(
                          # aggregate = "mean",
                          cell = data_bars(.,
                                           text_position = "above")
                          )
                      )
        })
    
    }

# Run the application 
shinyApp(ui = ui, server = server)

RKonstantinR avatar Feb 02 '24 06:02 RKonstantinR