kcuilla / reactablefmtr

Streamlined Table Styling and Formatting for Reactable
https://kcuilla.github.io/reactablefmtr/
Other
208 stars 27 forks source link

slow table render when using data_bars #66

Open RKonstantinR opened 10 months ago

RKonstantinR commented 10 months ago

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)