I have further debugged it to find out the formatting of the rows (specifically coloring them by condition) causes this when number of rows is in the order of thousands. Output is generated like follows:
% this part is okay
result <- scanResultsOrdered %>%
datatable(
selection = 'single',
extensions = c('FixedColumns', 'Buttons'),
rownames=FALSE,
options=list(
#dom = 't',
dom = 'Bfrtip',
scrollX=TRUE,
buttons = c(I('colvis'),'copy', 'print'),
fixedColumns = TRUE,
columnDefs = list(list(visible=FALSE, targets=match(columns2hide, colnames(scanResultsOrdered))-1L ))
))
% this part fails in chrome
result <- result %>% formatStyle(
'Root',
target = "row",
backgroundColor = styleEqual(unlist(scanResultsOrdered[[1]]) , values=c(rep("red", nRed),rep("yellow", nYel),rep("white", nWhi)))
)
And below is a reproducable example (running it on chrome should lead to same problem when number of rows are too large and row formatting is used):
require(shiny)
library(dplyr)
ui <- fluidPage(
titlePanel(title=h4("example", align="center")),
mainPanel(
DT::dataTableOutput('test')
)
)
##server
server <- function(input, output){
x<-tibble(a=c(1,2,3), color=c("red","yellow","white"))
x<-tibble(a=1:(4*10^3), color=c(rep("red", 2*10^3), rep("yellow", 1*10^3), rep("white", 1*10^3) ))
saveRDS(x,"./x.rds")
output$test<-renderDataTable({
data <- readRDS("./x.rds")
result <- datatable(data,
selection = 'single',
rownames=FALSE,
options=list(scrollX=TRUE)
)
result <- result %>%
formatStyle(
'color',
target = "row",
backgroundColor = styleEqual(unlist(data[["color"]]) , values=c(rep("red", 2*10^3),rep("yellow", 1*10^3),rep("white", 1*10^3)))
)
return(result)
})
}
shinyApp(ui = ui, server = server)